

echo $(ls)īoth of these tools are pretty core to shell scripting, you should learn both.įor completeness, as you indicate in the question, the other base way to convert stdin to command line args is the shell's builtin read command. You could also use the substitution command $() to do what you want. Just be sure to use relative pathnames (Section 31.2) that dont start with a slash - otherwise. As others have said, xargs is the canonical helper tool in this case, reading the command line args for a command from its stdin and constructing commands to run. The argument(s) to the reading-tar can be directories or files. At this point, I'm getting absolutely lost and have no idea where these issues are coming from. What you really want is to convert stdout of one command to command line args of another. loop through each subdirectory of a specified directory-check the directory is the specified directory or one of the subdirectories-run the directory's through tree and then generate an image of the tree using convert with the filepath removed. Will 'work', depending on what your definition of work is.īut what about the general case. One is to use a command that reads stdin and dumps to stdout, such as cat. Fine right? Well, echo ignores standard input and will dump its command line arguments - which are none in this case to - to its own stdout. So ls | echoĬonnects standard output of ls to standard input of echo. A pipe will connect standard output of one process to standard input of another. So this gives us a listing containing only. ls grep 'page' grep prints lines that match its search pattern. There is a distinction between command line arguments and standard input. We will use the shell special character to pipe the output from ls into grep.
