It's a bit of embarrassing question but i can not found the error. I am trying to do process substitution. Here is my code
while read compareFile1 <&3 && read compareFile2 <&4; do
echo compareFile1
echo compareFile2
done 3< <(tail -n+4 test2.txt) 4< <(tail -n+4 test2.txt)
but the error is,
sh.sh: line 7: syntax error near unexpected token `<'
sh.sh: line 7: `done 3< <(tail -n+4 test2.txt) 4< <(tail -n+4 test2.txt)
Any can help?
Process substitution is not an available feature in POSIX sh (
#!/bin/sh
, also invoked withsh yourscript
); despite tagging this question "bash", you're clearly executing your script with a non-bash shell (or are otherwise entering portability mode, as withset -o posix
).Use bash instead; thus, putting
#!/bin/bash
at the beginning of your script, or invoking it withbash yourscript
if specifying an interpreter manually.