Piping:
The pipe character, “|”, is used to chain two or more commands together. The output of the first command is “piped” into the next program, and if there is a second pipe, the output is sent to the third program, etc. For example:
ls -la /usr/bin | less
In this example, we run the command “ls -la /usr/bin”, which gives us a long listing of all of the files in /usr/bin. Because the output of this command is typically very long, we pipe the output to a program called “less”, which displays the output for us one screen at a time.
Redirection:
Redirection used for different purpose. Sometimes we want to input something in file without editing it with an editor. Example:
echo "this is a test" > test
It will enter the text "this is a test" in the file named test.
Sometimes we need to save the output of a command to a file without showing it in the display. Example:
grep "status=sent" /var/log/mail.log > /tmp/log
It will save the output of the command in the file, named log.
The pipe character, “|”, is used to chain two or more commands together. The output of the first command is “piped” into the next program, and if there is a second pipe, the output is sent to the third program, etc. For example:
ls -la /usr/bin | less
In this example, we run the command “ls -la /usr/bin”, which gives us a long listing of all of the files in /usr/bin. Because the output of this command is typically very long, we pipe the output to a program called “less”, which displays the output for us one screen at a time.
Redirection:
Redirection used for different purpose. Sometimes we want to input something in file without editing it with an editor. Example:
echo "this is a test" > test
It will enter the text "this is a test" in the file named test.
Sometimes we need to save the output of a command to a file without showing it in the display. Example:
grep "status=sent" /var/log/mail.log > /tmp/log
It will save the output of the command in the file, named log.
No comments:
Post a Comment