Sujet : Re: Using << and an output pipe together in shell (bash)
De : Lem (at) *nospam* none.invalid (Lem Novantotto)
Groupes : comp.unix.shellDate : 01. Nov 2024, 16:39:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vg2snp$36bh5$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Pan/0.160 (Toresk; )
Il Fri, 1 Nov 2024 09:01:15 -0000 (UTC), Kenny McCormack ha scritto:
I think I actually prefer to stick with; > >(cmd ...)
Note that
cat << EOF | grep . ; echo end
and also
(cat | grep .) << EOF ; echo end
produce the same output:
---------------------------------------------------------
lem@biggy:~$ cat << EOF | grep . ; echo end
start
EOF
start
end
lem@biggy:~$
---------------------------------------------------------
lem@biggy:~$ (cat | grep .) << EOF ; echo end
start
EOF
start
end
lem@biggy:~$
---------------------------------------------------------
Instead with "cat << EOF > >(grep .) ; echo end" the output is
unpredictable. You can very well get, as usual:
---------------------------------------------------------
lem@biggy:~$ cat << EOF > >(grep .) ; echo end
start
EOF
start
end
lem@biggy:~$
---------------------------------------------------------
OR maybe:
---------------------------------------------------------
lem@biggy:~$ cat << EOF > >(grep .) ; echo end
start
EOF
end
start
lem@biggy:~$
---------------------------------------------------------
OR even, most of the time:
---------------------------------------------------------
lem@biggy:~$ cat << EOF > >(grep .) ; echo end
start
EOF
end
lem@biggy:~$ start [you press ENTER here and get back an empty prompt]
lem@biggy:~$
---------------------------------------------------------
So sometimes it's better to be careful. :)
-- Bye, Lem