I a bash script I have the following
CMD="{ head -n1 $DATE.$FROMSTRAT.new && egrep -i \"$SYMS\" $DATE.$FROMSTRAT.new; } > $DATE.$TOSTRAT.new"
echo "Running $CMD"
`$CMD`
When I call the script
Running { head -n1 inputFile.new && egrep -i "X|Y" inputFile.new; } > outputFile.new
script.sh: line 17: {: command not found
But when I run { head -n1 inputFile.new && egrep -i "X|Y" inputFile.new; } > outputFile.new on the command line it works fine.
I try to escape the { with no success, how can I do this ?
evalor by passing it tobash -c "...". But in general that is not a good idea, error-prone, accidently clobbering files with weird input, debugging etc. Why the indirection?