The pipe is used to connect the output of one command line to take input in another command line.
Pipe Defined as:
"The pipe is nothing but is used as a temporary storage place where the output of one command line is stored and then it is passed as the input to the second command line. Pipes can be used to run more than two commands from at the same command line."
Syntax:
command1 | command2
Examples: | |||||
Command using Pipes | Meaning or Use of Pipes | ||||
$ ls | more | The output of ls command is given as input to more command So that output will be printed one screen full page at a time and we’ll be able to use space bar to see next page. | ||||
$ who | sort | The output of who command is given as input to sort command So that it will print the output of users in alphabetical order. | ||||
$ who | sort > users_list | The output of the above command will be saved in file named users_list. | ||||
$ who | wc -l | The output of the who command will be given as the input to wc command So that it could be display the number of user who is currently logged in to system. | ||||
$ ls -l | wc -l | The output of ls command will be given as input to wc command So that it will be able to print number of files in current directory available. | ||||
$ who | grep raju | The output of who command will be given to grep command as input So that it will able to print the output if a particular user name if he is currently logged in otherwise nothing will printed. |
0 Comments:
Post a Comment