Comments

Nested
commands which execute first
User: Kostas V
Date: 3/29/2013 5:20 am
Views: 7890
Rating: 16

Hello I want to ask a question. I have this coomand:

 cat in.txt | sed -e 's/$/'\'',/g' | sed -e 's/^/'\''/g' > out.txt

I want to know which command is executed first second etc.

I am not sure about this, it depends on the "|" ?

 

Thank you very much

Re: commands which execute first
User: kmaclean
Date: 3/29/2013 1:13 pm
Views: 522
Rating: 12

>I want to know which command is executed first second etc.

>I am not sure about this, it depends on the "|" ?

you want to look up info on pipes; from stackoverflow comment:

Piping does not complete the first command before running the second. Unix (and Linux) piping run all commands concurrently. A command will be suspended if

  • It is starved for input.

  • It has produced significantly more output than its successor is ready to consume.

For most programs output is buffered, which means that the OS accumulates a substantial amount of output (perhaps 8000 characters or so) before passing it on to the next stage of the pipeline. This buffering is used to avoid too much switching back and forth between processes and kernel.

PreviousNext