Re: sed problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jens,

----- Mensaje Original -----
De: "Jens Knoell" <jens@xxxxxxxxxxxx>
Fecha: Jueves, Marzo 4, 2004 6:08 pm
Asunto: sed problem

> Oke... sed-hell again.
> 
> Case: I have a file that has lines separated by pipe chars. I need 
> to split
> it back into a line-by-line file. So I tried this (the ^M has been 
> enteredby pushing Ctrl+V, Enter):
> echo "This|should|be|on|separate|lines" | sed -e "s/|/^M/g"
> 
> The result:
> linesate
> 
> I'm sure I'm missing something, but hours of googling didn't get me
> anywhere. Any ideas?

I think awk fits better for this task, IMHO of course :-)

csoler@gudu$ echo "This|should|be|on|separate|lines" | awk -F"|" '{for 
(i=1; i<= NF; i++) print $i}'
This
should
be
on
separate
lines

I hope this helps you...

Cheers,
César

-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux