How can I use the output of one command - line-by-line - into another command? I know how to do this with the | pipe symbol, but this uses the entire output in one command. I would like to go line by line... I think I need to combine the | and xargs but not sure.  redis-cli keys \* | redis-cli get [key would go here]
35787
Say I have this file:  hello world hello world   This program  #!/bin/bash  for i in $(cat $1); do     echo "tester: $i" done   outputs  tester: hello tester: world tester: hello tester: world   I'd like to have the for iterate over each line individually ignoring whitespaces though, i.e. the last two lines should be replaced by  tester: hello world   Using quotes for i in "$(cat $1)"; results in i being assigned the whole file at once. What should I change?
56340
Redirecting command output:  For example:  echo "Foo `./print_5_As.rb`"   would echo "Foo AAAAA"
96499
I have two programs, one of them prints something first, they need to communicate with each other with their standard IO.  Is there a way in Bash to pipe stdout of two programs to each other? I know I could do this in C with forks and dups, but is there a way with pure Bash?
10998
Is there a way that I can pipe the output of this command (assuming there is only one file found) to vi.  I want to find this command, and then call it up in vi.  Thanks.  find . -name 'id.properties'
3477
I don't quite understand how the computer reads this command.  cat file1 file2 1&gt; file.txt 2&gt;&amp;1  If I understand, 2&gt;&amp;1 simply redirect Standard Error to Standard Output.  By that logic, the command reads to me as follows:    concatenate files file1 and file2.  send stdout from this operation to file.txt. send stderr to stdout. end?   I'm not sure what the computer's doing. By my logic, the command should be   cat file1 file2 2&gt;&amp;1 &gt; file.txt   but this is not correct.
111307
Does an elegant way exist to save the output of a command to a file after the command has been run, while the terminal window is open i.e. once the command has been executed in the terminal?  The output is still present in terminal. Now I could copy &amp; paste all the lines and save it to a file.  But perhaps does a method exist to somehow write the output buffer of a terminal window to a file or even better the output of an already executed command?
54930
I'm looking to write a script that takes a .txt filename as an argument, reads the file line by line, and passes each line to a command. For example, it runs command --option "LINE 1", then command --option "LINE 2", etc. The output of the command is written to another file. How do I go about doing that? I don't know where to start.
92357
I have a text file with various IP addresses.   I would like to cycle through each, and issue a command:  cat ips.txt | xargs -L 1 `ssh me@__IP__ echo "text" &gt; file; reboot;`   But I'm unsure how to pass the xargs value to _IP_.  Could someone explain how this could be accomplished?
8122
In bash, calling foo would display any output from that command on the stdout.  Calling foo &gt; output would redirect any output from that command to the file specified (in this case 'output').  Is there a way to redirect output to a file and have it display on stdout?
63159
I was just running a few commands in a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands?  For example, let's say I have a file with one million lines, the first 10 of which contain hello world. If you run the command grep "hello world" file | head does the first command stop as soon as it finds 10 lines, or does it continue to search the entire file first?
19083
I viewed  to redirect text to file while displaying the output. My question is how can I redirect it while working AND without constant | tee command.  My plan is to use  to identify terminal (Gnome or Guake) and record only Gnome for my Linux commands testing. So I need constant and immediate redirecting of commands and their outputs (with errors) to a file (say cmdlog.log).
100276
I have a command that produces output in color, and I would like to pipe it into a file with the color codes stripped out. Is there a command that works like cat except that it strips color codes? I plan to do something like this:  $ command-that-produces-colored-output | stripcolorcodes &gt; outfile
21303
I'd like to know how to reuse the last output from the console, ie:  pv-3:method Xavier$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" /Library/Python/2.6/site-packages pv-3:method Xavier$ cd **LASTOUTPUT**
43246
The   echo one; echo two &gt; &gt;(cat); echo three;    command gives unexpected output.  I read this:  and many other articles about process substitution on the internet, but don't understand why it behaves this way.  Expected output:  one two three   Real output:  prompt$ echo one; echo two &gt; &gt;(cat); echo three; one three prompt$ two   Also, this two commands should be equivalent from my point of view, but they don't:  ##### first command - the pipe is used. prompt$ seq 1 5 | cat 1 2 3 4 5 ##### second command - the process substitution and redirection are used. prompt$ seq 1 5 &gt; &gt;(cat) prompt$ 1 2 3 4 5   Why I think, they should be the same? Because, both connects the seq output to the cat input through the anonymous pipe - .  Question: Why it behaves this way? Where is my error? The comprehensive answer is desired (with explanation of how the bash does it under the hood).
58533
I need join 2 lines into one in stdout - replace new line AND 4x space with one space but new line without space don't touch  tcpdump -vvv ... -l | xyz   this is output:  2014-06-06 AAA     BBB 2014-06-06 CCC     DDD   but I need:   2014-06-06 AAA BBB 2014-06-06 CCC DDD
65734
Considering a routine such as this one:  alpha() { echo a b c |tr ' ' '\n'; }   which outputs a stream, I would like to take the output stream, transform it, and paste it with the original output stream.  If I take use upcasing as a sample transformation, I can achieve what I want with:  $ mkfifo p1 p2 $ alpha | tee p1 &gt;( tr a-z A-Z &gt; p2) &gt;/dev/null &amp; $ paste p1 p2 a       A b       B c       C   My question is, is there a better way to do this, preferably one not involving named pipes?
122811
Occasionally I need to specify a "path-equivalent" of one of the standard IO streams (stdin, stdout, stderr).  Since 99% of the time I work with Linux, I just prepend /dev/ to get /dev/stdin, etc., and this "seems to do the right thing".  But, for one thing, I've always been uneasy about such a rationale (because, of course, "it seems to work" until it doesn't).  Furthermore, I have no good sense for how portable this maneuver is.  So I have a few questions:   In the context of Linux, is it safe (yes/no) to equate stdin, stdout, and stderr with /dev/stdin, /dev/stdout, and /dev/stderr? More generally, is this equivalence "adequately portable"?   I could not find any POSIX references.