All processes have (from os) std steams, to which they can read/write.
- cin
- cout
- cerr
Default
- keyboard - cin ,
- screen - cout, cerr
But can be changed by
- Redirect to/from file
- cin (<)
c < file_incin of process c is file called file_in
-
cout(> or 1>), cerr (2>)
c1> file_outc1 1> file_outcout of c1 is file called file_out
-
c1 2> file_err
cerr of c1 is file called file_err -
c1 2> file_err > file_out
cerr of c1 is file called file_err, and its cout is file called file_out
c1 > file_both 2>&1c1 > file_both &>cerr and cout ...... file_both (note: order of matters:c1 2>&1 > file_bothis not the same - cerr goes to the original dest of cout)
- cin (<)
-
Pipe ( | ) between processes
-
c1 | c2cout of c1 is cin for c2- Note: c2 does not wait for c1 to finish before starting - both c1 and c2 are started (almost) simultaneously.
c1 | tee [-a] file_outtee writes it cin to both its cout and file_out (appending if -a is specified)
-