Using piped examples with tee and xargs .

The | operator makes bash redirect all data that the command left of it returns to the stdout
Let’s try a more complex example.
If you want to see the data and write to the file passed on between programs in a pipe, you can insert the tee command.

The data shown by ps aux is written by tee to file named filename and is piped to grep to show only the root expression.
The command xargs can feed arguments, usually imported through a pipe, to a command.
The next example will show how to use xargs.

The command ls -l show the files and folders.
The output is piped by | to the xargs.
The command xargs will execute echo {}.
The {} will be replaced by xargs with the argument, in this case with the output piped by ls -l.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.