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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -