What I am trying to do is run a bash script that looks somewhat like this:
#!/usr/bin/bash
only1=$(comm -23 $1 $2 | wc -l)
only2=$(comm -13 $1 $2 | wc -l)
common=$(comm -12 $1 $2 | wc -l)
echo -e "${only1} only in $1"
echo -e "${only2} only in $2"
echo -e "${common} in both"
If I execute the script as script.sh file1 file2
it works fine. However, if I use it as script.sh <(grep 'foo' file1) <(grep 'foo' file2)
it fails because the virtual files of the kind dev/fd/62
are only available for the first command (only1
in the script). The output is:
262 only in /dev/fd/63
0 only in /dev/fd/62
0 in both
Is there a way to make these virtual files available to all of the commands in the script?