Advertisement
Advertisement


Debugger for unix pipe commands


Question

As I build *nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I usually do this by sending the result of each command to a temporary file (i.e. tee or run each command one at a time) but it would be nice for a program to handle this.

I envision something like a tabbed interface where each tab is labeled with each pipe command and selecting a tab shows the output (at least a hundred lines) of applying that command to to the previous result.

1
4
9/19/2008 3:07:19 PM


You can also use pipes if you need bidirectional communication (i.e. with netcat):

mknod backpipe p
nc -l -p 80 0<backpipe | tee -a inflow | nc localhost 81 | tee -a outflow 1>backpipe

(via)

2008/09/15

tee(1) is your friend. It sends its input to both the specified file and stdout.

Stick it between your pipes. For example:

ls | tee /tmp/out1 | sort | tee /tmp/out2 | sed 's/foo/bar/g'
2009/02/28

There's also the "pv" command - available in debian / ubuntu repostitories which shows you the throughput of your pipes.

An example from the man page : Transferring a file from another process and passing the expected size to pv:

          cat file | pv -s 12345 | nc -w 1 somewhere.com 3000
2008/09/15

Source: https://stackoverflow.com/questions/63771
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]