linux - Simple shell. Mixed pipes and output -
let's consider:
cat > outout.txt | cat > outout2.txt
i don't know how interpret this. input second command?
when cat doesn't receive filename argument, takes input stdin , sends stdout, effect of first part of command chain put whatever typed (until eod) file outout.txt:
cat > outout.txt
if goes normally, command produces no output, , second part of command chain gets nothing put outout2.txt:
cat > outout2.txt
so file outout2.txt made empty full command chain:
$ cat > outout.txt | cat > outout2.txt
note, however, outout2.txt will output if first "cat" invocation generates output. example, if outout.txt cannot modified , send stderr output stdout:
$ chmod a-w outout.txt $ cat 2>&1 > outout.txt | cat > outout2.txt
then outout.txt empty, following text written outout2.txt (the exact text of message may depend on shell - i'm using bash 3.2):
-bash: outout.txt: permission denied
Comments
Post a Comment