Using sed to convert a string to a character?
I need a command that will take a text file, and
convert carriage return, linefeed into a space,
but convert 2 consecutive carriage return linefeeds
into 1 or a single linefeed or cr.
Does anyone know sed well enough to do that for me?
i could only get sed to change one character into another,
but not change 4 characters into 2 or 1.
how about using tr instead?
tr 'list-of-characters-to-change' 'character-to-change-to'
I tried tr first. I can only get it to change one
character into another, but i couldn't get it to
change a string to a character. I was trying
stuff like the below. tr man page only says stuff
about changing single characters into single
tr '\015\012' '\012' < $1 > $1.tmp.$$
what i did yesterday for lack of a better way, was to
use tr to change the newlines and carriage returns
to Capital Z's. Then i opened a text editor and
search and replaced each instance of ZZZZ with
a ~, then search and replaced each ZZ with a space.
then i used tr and converted each ~ to a new line.
Every couple of years i end up trying to do something
like this, and can't find a good way, short of writing
a little c program, which i do so rarely, i have to
relearn every time.
|All times are GMT -5. The time now is 07:58 AM.|