Friday, August 15, 2008

Pipe

Pipe

Pipe command can use to combine two commands or more. That means output of one command will input for the next command.
command 1 | command 2


As an example
ls -l | less
This command displays ls -l results page by page. We can move up and down using arrow keys.

'more' is smiler to less command. But more doesn't support for arrow keys.

Example with more than two commands
ls -l| head -4| tail -1



important : command connected using pipe are execute separately and simultaneously.
Normally in piping standard output is redirected to the next command. That means not the standard error.
Let's see
ls -l myFolder | wc -l
where myFolder directory doesn't exist.
This command makes the output as 0.

No comments: