4 ms·
I have problems understanding what commands I can pipe. Some work some don't.
by nickthemagicman 6y ago
I have problems understanding what commands I can pipe. Some work some don't.
- ketanmaheshwari 6y agoThe commands that read their input from standard input could be used as receiver in a pipeline. For instance: `A | B` is a short form of `A > tmp.txt; B < tmp.txt; rm tmp.txt` There are some commands that need literal arguments which is different than standard input. For instance the echo command. `echo < list.txt` will not work assuming you want to print the items inside the list. `echo itemA itemB itemC` will work. This is where xargs comes into play -- it converts the standard input stream to literal arguments among other things.
- nickthemagicman 6y agoHow do you know which ones receive input from standard input or how can you find out efficiently?
- ketanmaheshwari 6y agoThe man page of the command helps in most cases. Often the description section has info if the command reads from standard input, a file or both.
- mehrdadn 6y ago--help is a great one. When you want to search the help output you can either feed it into grep or not... depending on whether the program writes to stdout or stderr. You can force writing to stdout via adding 2>&1 at the end of your command. (It's possible that's what you're running into.)
- cptnapalm 6y agoAs everything gets tossed into bin, there's no easy way to find out what is and what isn't a tool or filter rather than an application. It makes discovery difficult.