I want to store the ouput of a command into an array. I tried with the below command which I got from a similar question asked here. Please find below the shell comamnds I used:
#!/bin/ksh
mailx -H >mytest.txt
#awk '/Incident/{ print NR;}' mytest.txt >lineNum.txt
msgNumbers=$(awk '/Incident/{ print NR;}' mytest.txt)
echo $msgNumbers
I am able to get the required result directly executing this command in UNIX. But when I am using the same command within a shell script, I am getting an error:
"syntax error at line 5: `msgNumbers=$' unexpected"
Could someone point out the error in it?
msgNumbers
in there (and only one line instead of 5). Please edit your question to show the actual command you're running. You can remove the irrelevant parts or any secret data, just make sure to reduce it to a piece of code that actually shows the error.