Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there process substitution in Bourne Shell like that in Bash?

I'm trying to use cmp to compare outputs of two commands (Bourne shell):

cmp <(ls $file1) <(ls $file2)

It works well in Bash but cannot work in Bourne. Is there any solution? Thanks so much!

like image 662
Sharon Avatar asked Sep 06 '25 08:09

Sharon


1 Answers

Process substitution is (or used to be) implemented using named pipes. You could use mkfifo directly to recreate the same behavior:

mkfifo pipe1 pipe2
ls $file1 > pipe1 &
ls $file2 > pipe2 &
cmp pipe1 pipe2
rm pipe1 pipe2

But besides performances, you won't gain much compared to going thought regular files...

like image 155
OlivierBlanvillain Avatar answered Sep 10 '25 17:09

OlivierBlanvillain