sed and appending data to the end of every line

sed and appending data to the end of every line

Post by Gary Quirin » Fri, 05 Jan 2001 06:48:21



I would like to append the pipe character to the end of every line in some
print files to be imported into an Informix table.

I have tried the following and just don't understand how to quote for a new
line.

sed s/\/n/\/n\|/g infile>outfile

Thanks
Gary Quiring

 
 
 

sed and appending data to the end of every line

Post by roid.. » Fri, 05 Jan 2001 08:06:18




Quote:> I would like to append the pipe character to the end of every line in
some
> print files to be imported into an Informix table.

> I have tried the following and just don't understand how to quote for
a new
> line.

> sed s/\/n/\/n\|/g infile>outfile

> Thanks
> Gary Quiring

At times, sed mystifies me, but how to do this in awk, I know.

awk '{printf ("%s|\n", $0)}' yourfile

There are perhaps more elegant ways, but this is off the top of my head.

Sent via Deja.com
http://www.deja.com/

 
 
 

sed and appending data to the end of every line

Post by mjnem.. » Fri, 05 Jan 2001 21:33:00


sed ' s/$/\|/ ' infile >outfile

$ is the EOL reqular expression character  (^ gets you BOL )

RTFM



Quote:> I would like to append the pipe character to the end of every line in
some
> print files to be imported into an Informix table.

> I have tried the following and just don't understand how to quote for
a new
> line.

> sed s/\/n/\/n\|/g infile>outfile

> Thanks
> Gary Quiring

Sent via Deja.com
http://www.deja.com/
 
 
 

sed and appending data to the end of every line

Post by Gary Quirin » Sat, 06 Jan 2001 01:40:16




>> sed s/\/n/\/n\|/g infile>outfile

>No. Sed is a line-based editor, so you don't need to specify \n. Just specify
>$ to match the EOL:

>sed 's/$/|/' infile > outfile

>Moshe

Thanks, it works great!!

Gary