Monday, February 4, 2013

Unix dash (-) symbol = stdin placeholder

(a)
~/home/user > echo '"4 plum"' | cat data/rg.txt -
    ID:ga    SM:hs    LB:ga    PL:Illumina
    ID:454    SM:hs    LB:454    PL:454
"4 plum"


(b)
~/home/user > echo '"4 plum"' | cat - data/rg.txt
"4 plum"
    ID:ga    SM:hs    LB:ga    PL:Illumina
    ID:454    SM:hs    LB:454    PL:454

So in the above examples, the (-) character puts the contents of stdin ("4 plum") before (b) or after (b) the contents of file "data/rg.txt".

       cat f - g
              Output f’s contents, then standard input, then g’s contents.

No comments: