replacing two EOL chars by one
Ragnar Hafstað
gnari at simnet.is
Sat Dec 20 15:45:56 EST 2003
"Xah Lee" <xah at xahlee.org> wrote in message
news:7fe97cc4.0312201204.7accda32 at posting.google.com...
> i have a bunch of java files that has spaced-out formatting that i
> want to get rid of. I want to replace two end of line characters by
> one end of line characters. The files in question is unix, and i'm
> also working under unix, so i did:
>
> perl -pi'*~' -e "s@\n\n@\n at g" *.java
>
> but this to no avail.
>
snipped long rant about perldocs
the problem is not your understanding of regular expressions,
but rather that you are forgetting what -p does
you are applying the -e commands to each line of input in turn before
printing it. no line of the input contained \n\n as then they would not
have been ONE line.
now, to do what you want, try:
perl -0 -pi'*~' -e 's@\n\n@\n at g' *.java
More information about the Python-list
mailing list