Get good command line habits
February 28, 2008 by Clair Ching
Filed under General, How To
I must confess. I have bad command line habits! I make directories and subdirectories, one directory at a time… Meaning, I make a directory then cd to that then make a subdirectory from it. However, I learned today that I don’t have to do that. Thanks to the article: Learn 10 good UNIX usage habits. It lists down the bad habits and the good ones.
Part of how the bad command line habits have been formed when I think about the way it is on the graphical user interface, like what steps I have to take. These days I’ve been mainly reliant on Gnome so I have lost practice using the command line.
Another snippet from the article:
Stop piping cats
A basic-but-common grep usage error involves piping the output of cat to grep to search the contents of a single file. This is absolutely unnecessary and a waste of time, because tools such as grep take file names as arguments.
If you have been doing these same things, it’s time for us to learn these good command line habits together!

















There is one tip for bash that is not in that article and is REALLY useful: lists in { }
for example, let’s try this:
mkdir {a,b}/{1,2,3}
this will create the following structure:
a/1
a/2
a/3
b/1
b/2
b/3
The posibilities for this are really interesting, and it is a powerful feature. For example, let’s say that you have files for 02-28 and 02-27 and want to move them:
# ls -1
log_02-28
log_02-27
# mv (or cat, or cp, or whatever) log_02-2{7,8}
Bash is powerful, but you need a lot of practice to master it. I’m proud to be slowly walking that road