Next: Directories
Up: Commands
Previous: Simple Commands; date, whoami,
Contents
- Items;
- Your home directory - cd, pwd
- Creating short files - cat, ls
- Examining files -- wc, grep , sort
- Getting rid of files - rm
- $cd The cd command ( change directory) used with no arguments takes us from wherever we might be to our home directory.
- $pwd The pwd ( print working directory) tells in which directory we find ourselves for the moment.
- $echo $HOME Note that echo $HOME has exactly the same effect as pwd. Figure out what your home directory is.
- $cat dict
red: rojo
yellow: amarillo
black: negro
white: blanco
blue: azul
green: verde
control-d
By control-d we mean: hold the control key down; while it is down press "d". We have just used cat to create a short English-Spanish dictionary. This dictionary resides in the file dict.
- $ls dict The ls command lists the files in the current directory. For the moment there is only one, namely dict.
- $cat dict The command cat shows us what is in dict.
red: rojo
yellow: amarillo
black: negro
white: blanco
blue: azul
green: verde
- $wc dict wc command counts words (and more). In the case at hand it tells us that dict contains 6 lines, 12 words, and 78 characters ("letters").
6 12 78
- $grep white dict The grep command looks for the word white in the file dict and displays the lines in which this word appears. It gives us a way to search through files.
white: blanco
- $sort dict The sort command does just what it says.
black: negro
blue: azul
green: verde
red: rojo
white: blanco
yellow: amarillo
- $sort dict dict2
$ls dict dict2
$cat dict2
black: negro
blue: azul
green: verde
red: rojo
white: blanco
yellow: amarillo
Notice once again the use of the "into" symbol "". In our example it had the effect of directing the output of the sort command from the screen to the file dict2. Just to be sure that everything went according to plan, we used ls to be sure that dict2 was there, and we used cat dict2 to be sure that it contained what we thought it should.
- $rm dict2 we use the rm command (for re move).
Next: Directories
Up: Commands
Previous: Simple Commands; date, whoami,
Contents
Cem Ozdogan
2009-05-11