I am writing a bash script in which I am using comm command, I keep getting the error
san.sh: line 12: syntax error near unexpected token `('
san.sh: line 12: ` comm < (grep -r --include "collect.xml" "mean enabled=\"true\"" /opt/Test/test1 | grep -v bak | awk -F/ '{print $7}' | sort -u) < (cat /etc/bruce/wayne/mansion.ini | grep LogType | cut -d "=" -f 2 | sort -u)'
comm < (grep -r --include "collect.xml" "mean enabled="true"" /opt/Test/test1 | grep -v bak | awk -F/ '{print $7}' | sort -u) < (cat /etc/bruce/wayne/mansion.ini | grep Type | cut -d "=" -f 2 | sort -u)
If I where to run the command in the terminal I get the desired output only in the script does it through this error :(
comm <(echo foo) <(echo bar)
would be enough here to trigger the syntax error. – ilkkachu Sep 05 '21 at 10:14sh
, notbash
. From the error message it looks like yoursh
is Bash, but insh
mode it doesn't support process substitutions, which is why you get the error. Run the scripts withbash
, or add the execute permission and run them as./san.sh
so that the hashbang applies.