Click to See Complete Forum and Search --> : Adding text at the end of each line


Zoist
03-05-2003, 11:40 AM
I have a plain text file with lines of text and need to place a pipe | at the end of each line.
Could anyone help me with this?
Thanks!

Pierre Lambion
03-05-2003, 12:20 PM
Not at my linux box here but in vim or with sed, something like
s/$/\|/g
should do the trick, you should read it

s(ubstitute) / $(end of line) / with | (escaped by \) / g(lobally)

Do backups first!

P.

Haunted
03-05-2003, 12:34 PM
perl -pl -e 's/\n/\|\n/g' yourfile


just as last poster said - BACKUP!

Zoist
03-05-2003, 02:05 PM
Originally posted by Pierre Lambion
Not at my linux box here but in vim or with sed, something like
s/$/\|/g
should do the trick, you should read it

s(ubstitute) / $(end of line) / with | (escaped by \) / g(lobally)

Do backups first!

P.

Worked great. Thank you so much :)