[Sig] Re: [Lvlug] How to run SED
Fri, 23 Feb 2001 07:38:53 -0500
Thanks! The missing asterisk was the key -- it should have been:
for f in *,v; ...
The $f was required (in "$f > x") -- I'nm not exactly sure why, but with
that, the sed command created a new copy of each file, replacing
"nobody" with "apache". The "mv x $f" then replaced the original file
with the copy which was exactly what was needed.
It then ran as all one line entered at the command line.
I'm going to experiment with eliminating white space so it fits all on
one line, and also as a #!/bin/bash file -- would it work on multiple
lines then? Would I still need the ";"s?
> The snippet:
> for f in ,v; do sed 's/nobody\:/apache\:/' $f > x; mv x $f; done
for f in *,v; do sed 's/nobody\:/apache\:/' $f > x; mv x $f; done
> Yeah, fix their code... The "for f in" part designates a file loop, but the ",v" should be a condition and not a variable.. Something like "for f in *.txt" would look at all *.txt files in the current directory.