7/23 How do you do this in sed, not perl?
s/(.*).gif/$1th.gif/;
s/(.*).gif/\1th.gif/
\_ sed: 1: "s/(.*).gif/\1th.gif/": \1 not defined in the RE
\_ try this instead (ugly, but works): sed 's/.*/&th.gif/;s/.gif//'
\_ sed 's/\(.*\)\.gif/\1th.gif/'
(sed uses \( and \) to mean "save this") also,
don't forget to \ the . so it doesn't mean "any character"
--dbushong
\_ woo woo, that's what i was looking for. you da man!
\_ This being said, perl regexps are significantly nicer
than sed, perl -e 'regexp' is nicer than sed 'regexp'
And if you're applying it to an entire file in place,
you can say perl -pi -e 'regexp', whereas you need to
create tempfiles for sed.. --dbushong
\_ but this is what i wanted to do:
foreach f (*.gif)
mv $f `echo $f | sed 's/\(.*\)\.gif/\1th.gif/'`
end
it seems like it's better done at the command
line. I didn't think you can do that in as few
bytes (and processes) in perl.
\_ You can do it in 1 process, and approximately
the same number of bytes, in perl. -tom
\_ Yeah? So? sed is for real men. You sound like a
limp-wristed, lisping girly-man. You probably use
emacs instead of ed, too, I'll bet.
\_ ed? You pansy faggot! I use cat, don't make any
mistakes and never need to edit a file because I
thought ahead and did it right the first time!
\_ why are perl regexps "nicer"?
\_ In general, they require fewer backslashes, support
all the standard operators, and add some new and
useful (if tricky) things like non-greedy qfiers. |