Some of the most used UNIX
commands are as follows:
- ls
- pwd
- cd
- mkdir
- touch
- mv
- cp
- | - to pass the output from one command as the input to another command
Pipes is an interesting one. For instance we can get the word count of two files with |
Redirection
Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection allows commands’ file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to.
When bash starts it opens the three standard file descriptors: stdin (file descriptor 0), stdout (file descriptor 1), and stderr (file descriptor 2).
- Redirect the
stdout
to a file:
- Redirect the
stderr
to a file:
- Redirect both
stdout
andstderr
to a file:
&>
operator redirect bothstdout
and stderr
to the file.
There are other ways to do it as well:
2>&1
duplicates the file descriptor 2 to be a copy of the file descriptor 1
Grep - Global Regular Expression Print
To put it simply, it does what regular expression does