A Few Shell Commands
Shell is a program running between the kernel and the user. The users are actually communicating with the shell not with the kernel.
Here are a few shell commands:
- * – pattern matches any string of characters.
eg: wc ch1.*
- ? – pattern matches any single character.
eg: ls -l ch?.1
- […] – pattern matches any of the characters inside the bracket.
eg: pr ch*
To avoid special meaning of *, ?, etc.., we have to use single quotes. i.e. ls ‘?’
ls >file – the output is redirected to the file named file.
>> adds the output to the end of the file whereas > replaces the old file.
sort <temp – sorts the content of the file temp.
If we want to redirect the output of a program to the input of another without creation of a temporary file we can use pipes(|).
who|sort – print sorted list of users.
Two programs could be run with one command by separating them with a semicolon(;).
To run a program in the background and return to the terminal can be done using an ‘&‘.
wc ch* >wc.out &
We can continue running a program even if we logout using the command ‘nohup’.
nohup command &
To start a process at some hour of a day we can use the command ‘at’
at 3am <file
stty erase ‘^h’ – makes control h equivalent to backspace.
PS1=’hai :’ – makes the prompt appear as hai :
We can use variables for abbreviations of very long directory name. Add a name like
in our profile i.e. .profile file in the login directory. Now we can use the abbreviation as
To find the login directory we can use the command pwd.