Replacing two EOL chars by one

“Xah Lee” xah@xahlee.org wrote in message
news:7fe97cc4.0312201204.7accda32@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@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@g’ *.java