6 clever command-line tricks for fewer key strokes

Linux commands offer a lot of flexibility. This post details some ways to make them even more convenient to use by making use of some clever tricks.

Using file-name completion

You can avoid typing a full file name by typing the beginning of its name and pressing the tab key. If the string uniquely identifies a file, doing this will complete the filename. Otherwise, you can enter another letter in the name and press tab again. However, you can also get a list of all files that begin with a particular string by typing the string and then hitting the tab key twice. In this example, we do both:

$ ls di<tab><tab>
diff-commands dig.1 directory
dig.2 dimensions disk-usage-commands
$ cd dir<tab>
$ pwd
directory
[Find out how MINNIX was used as the inspiration for Linux.]
 
Reusing commands and changing them

Reissuing recently used commands is easy in bash. To rerun the previous command, all you have to do it type !! on the command line. You can also reissue a command with changes. If you issued the first command shown below only to find that sshd wasn’t running, you could issue the second command to start it. It simply replaces “status” with “start”.

To read this article in full, please click here

Source:: Network World – Data Center