
It converts "words" (words as defined by the IFS variable) to a temp variable, which you can use in any command runs. To get the same result, I am storing my search on a variable and then using find on it but obviously I am not satisfied with it.
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. 1 echoYou could also use the substitution command $() to do what you want. > redirects the output of a command to a file, replacing the existing contents of the file. 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. Option One: Redirect Output to a File Only To use bash redirection, you run a command, specify the > or > operator, and then provide the path of a file you want the output redirected to. What you really want is to convert stdout of one command to command line args of another. 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. It supports basic and extended regular expressions that allow you to match complex patterns.

With sed, you can search, find and replace, insert, and delete words and lines.

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. It can perform basic text manipulation on files and input streams such as pipelines.

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. There is a distinction between command line arguments and standard input.
