Some useful Linux commands and tricks for the bash shell user.

Posted: May 18, 2014. At: 10:03 PM. This was 3 years ago. Post ID: 7286

The boxes utility for Linux allows you to render an ascii text box around text. Below is an example.

homer@homer-eME730 19:14:21 ~ $ echo `echo "This is a sentence printed to the terminal."` | boxes
/***********************************************/
/* This is a sentence printed to the terminal. */
/***********************************************/

This is a useful utility if you want a text box around your message.

Here I am using sed to replace a word in the sentence printed to the terminal.

homer@homer-eME730 19:30:28 ~ $ echo `echo "This is a sentence printed to the terminal."` | sed 's/sentence/paragraph/gi;'
This is a paragraph printed to the terminal.

Print where you are in the dir tree with this command.

homer@homer-eME730 19:30:52 ~ $ echo $DIRSTACK
~

Or use pwd.

homer@homer-eME730 19:37:17 ~ $ pwd
/home/homer

How to print the directory tree to the preceding directory with the Linux command line.

homer@homer-eME730 19:39:41 ~/Documents $ echo ${OLDPWD}
/home/homer

And this is the environment variable that will print the value of pwd.

homer@homer-eME730 19:41:02 ~/Documents $ echo ${PWD}
/home/homer/Documents

More awesome Linux shell tricks: http://www.securitronlinux.com/bejiitaswrath/more-awesome-shell-tricks-for-the-linux-command-line-this-is-using-the-bash-shell/.

Even more awesome Linux shell tricks: http://www.securitronlinux.com/bejiitaswrath/cispa-bill-still-a-threat-and-awesome-linux-shell-tricks/.

No comments have been made. Use this form to start the conversation :)

Leave a Reply