1830936 Members
1959 Online
110017 Solutions
New Discussion

remove new line

 
ousseynou diagne
Occasional Contributor

remove new line

How to remove the LAST new line in a file in HP-UNIX?
Thanks,
Jahn
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: remove new line

Hi:

If you truly mean *only* the last newline character:

# perl -pe 's{\n}{} if eof' file

If you (on the other hand) simply mean the last *line*, then:

# perl -pe 'last if eof' file

Regards!

...JRF...
ousseynou diagne
Occasional Contributor

Re: remove new line

Thanks. I will try your solutions.
Jahn
Hein van den Heuvel
Honored Contributor

Re: remove new line

More importantly, please try to explain the actual problem.
We are all curious whether you really meant what you wrote (#1), or what JRF (and myself) think you meant to ask.

The solutions of course work for the problems JRF describes. Whether that corresponds your problem is the realy questions.

fwiw,
Hein.