next up previous [pdf]

Next: Interacting with files from Up: Command line interface Previous: Self-documentation

Piping

Sometimes we want to chain multiple commands together without writing intermediate Madagascar RSF files in the process. We can avoid making intermediate files by using another standard UNIX construct, pipes. Pipes allow us to connect the standard output from one Madagascar program to the standard input to another program without first writing to a file. For example we could do the following without pipes:
sfwindow < file.rsf > file-win.rsf
sftransp < file-win.rsf > file2.rsf
Or we could do the equivalent using pipes on one line:
sfwindow < file.rsf | sftransp > file2.rsf
Pipes simply make these statements more compact, and allow us to reduce the number of files that we need to save to disk. Piping is very powerful, because there is no limit to the number of statements that you can pipe together. For example:

sfwindow < file.rsf | sftransp | sfnoise var=1 > file2.rsf
If you're using multiple programs, and do not want to save the intermediate files, then pipes will greatly reduce the number of files that you have to keep track of.




2011-11-03