ithelp
Nearly a Posting Maven
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
for i in `grep "/\\*" file.c`; do
You need to escape the escape character when doing this inside of the expression quotes.
Edit: Which, I believe, is what ithelp meant, but he mistakenly used /// instead of /\\.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
It is because of file name expansion in the shell.
Just for fun try it this way
for i in `grep "/\\*" file`; do
set -f i=$i
echo "$i"
done
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Ok, unfortunately, the only thing left to do, that I can think of, is to do the script this way:
#!/bin/sh -f
for i in `grep "/\\*" file`; do
echo "$i"
done
And start the entire script without file name generation. That means, however, that file name expansion/generation does not work at all in the script, which may be wholly unenjoyable, but at least this part works.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Different. Although I don't really know why sourcing the script, rather than simply running it, would make a difference in the way set -f acts, but, oh well.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494