Posted: . At: 10:03 PM. This was 10 years ago. Post ID: 7286
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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

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/.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.