Reputation: 969
I have a portion in my script which gets the number of files based on the filelist.txt. I'm using this command to store the number to a variable.
filecount=$(wc -l ${script_path}/$filelist.txt | cut -d " " -f 1)
It works ok in my CentOS VM Image, but when it is executed in a UNIX environment it shows this error:
/myscript.sh: syntax error at line 50: `filecount=$' unexpected
./myscript.sh: [[: not found
The filelist contains this which actually just contains a listing of expected files to be processed.
File1
File2
File3
Appreciate any thoughts on this? Does cut not applicable to unix? What alternative methods can I use to get the desired result?
Thanks!
Upvotes: 0
Views: 26
Reputation: 61
I can't test on an UNIX sh
but I think you just have to replace $()
with ``
filecount=`wc -l ${script_path}/$filelist.txt | cut -d " " -f 1`
Regards
Upvotes: 1