I am writing a script to read the output of a command to variable a and b. This is the script#!/bin/bashread a b < <(awk '/Application Server/ && !seen[$7]++{printf %s , $7}' /tmp/ServerState)echo The value of a is $aecho The value of b is $band getting the syntax error as : line 3: syntax error near unexpected token `<'line 3: `read a b < <(awk /Application Server/ && !seen[$7]++{echo %s , $7} /tmp/ServerState)'But when I am typing the same command in the console it is working for me without any issue.app@user:/tmp> read a b < <(awk '/Application Server/ && !seen[$7]++{printf %s , $7}' /tmp/ServerState)app@user:/tmp> echo $aFAILEDapp@user:/tmp> echo $bSTARTEDAny help on this is really appreciated.
syntax error near unexpected token `
bash;shell script;process substitution
sh (which in most (Debian-derived) systems is linked to dash) doesn't allow process substitution. Try invoke by bash script.sh. Same calling by ./script.sh executes with sha-bang which is /bin/bash in your script.