I have a bash script that essentially run a computed grep command against a file:
cat $myfile | $string
where myfile, is a list of words and string, is a grep command with parameters:
/usr/bin/grep -v -e b -e j -e k -e l -e m -e q -e v -e x
The grep parameters are computed earlier in the script from a another process
When I run the command, cat $myfile | $string, from the console I get the expected output.
When the command runs from a script, I get:
./sp2: line 126: /usr/bin/grep -v -e b -e j -e k -e l -e m -e q -e v -e x : No such file or directory
This is running through cygwin, and really did work several years ago. Now... not so much.
If anyone has any ideas on what the issue is, and how I can resolve it, I would certainly appreciate it.
Cheers!
myfileorstringthat's se to that command? Storing commands in variables isn't a good idea; see [BashFAQ #50: I'm trying to put a command in a variable, but the complex cases always fail ](mywiki.wooledge.org/BashFAQ/050) As for the actual problem, have you by any chance changedIFS?IFS. If you need to store a list of files, use an array rather than a plain variable, and expand it with"${filearray[@]}". See BashFAQ #20: How can I find and safely handle file names containing newlines, spaces or both? for more tricks.