LA.pm: Pipes

Arkadiy Sudarikov asudarikov at xceed.com
Wed Jan 9 14:44:24 CST 2002


Hi, all.

I have another Shell (sh) question.

cat /etc/passwd | cat - > file || echo Bad Shit

Here, I get Bad Shit if my second cat (cat - > file) fails but not if it
succeds- regardless of what the exit status my first cat (cat /etc/passwd)
is, because || only acts on exit status of last command executed. Can anyone
think anything else that will give me Bad Shit if my first OR second command
fails?

Techincally, I need to do cat /etc/passwd && cat - > file || echo Bad Shit
but can I pipe in this case?

Any help helps.

Thanks,
Arkadi



More information about the Losangeles-pm mailing list