Feb

24

Unix Shell Command Line Tips

February 24, 2008 |

There are two major time-savers when dealing with long files on the command line (Unix Shell) : file globs and tab completion. File globs are symbols you can use as wildcards in the place of a filename. You can substitute the ? symbol for any single character in a filename, and * for any number of characters in a filename. For instance, say you had three files: car, bus, and cab. If you wanted to delete both car and cab, you would type:
rm ca?


The ? matches both r and the b at the end of the filename. If you wanted to remove all files that started with the letter b, you would type:
rm b*

Tab completion is another time-saver on the command line. If you start to type a command and then hit the Tab key, the shell will automatically attempt to complete the name of the command for you. In the case that more than one command matches what you have typed so far, hit Tab an extra time, and you will be shown all of the options that match:

apt-get followed by hitting the tab key twice.

Tab completion also works for files and directory names. Just type the first part of the filename and hit Tab, and the shell will fill out the rest for you.Once you are finished with a terminal, you can close the window like any other window, or, alternatively, you can type exit on the command line.



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

Sponsors




Links