sed problem
Hi Jens,
----- Mensaje Original -----
De: "Jens Knoell" <[email protected]>
Fecha: Jueves, Marzo 4, 2004 6:08 pm
Asunto: sed problem
Quoted 8 lines
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"
Quoted 5 lines
The result:
linesateI'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
linesI hope this helps you...
Cheers,
César
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
I think "tr" does this even easier (IMHO of course ;)
hal:~ # echo "This|should|be|on|separate|lines" | tr \| \\n This
should
be
on
separate
lines
Quoted 17 lines
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
linesI hope this helps you...
Cheers,
César
Quoted 8 lines
-
To unsubscribe from this list: send the line "unsubscribe linux- admin"
in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
sed 's/|/\n/g'
(( I like using single quotes, because you're less likely to get
characters like '\' and '$' eaten by the shell ))
Quoted 40 lines · [email protected] wrote:
Hi Jens,
----- Mensaje Original -----
De: "Jens Knoell" <[email protected]>
Fecha: Jueves, Marzo 4, 2004 6:08 pm
Asunto: sed problemQuoted 11 lines
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:
linesateI'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 linesI hope this helps you...
Cheers,
César-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 8 lines
Stephen Samuel +1(604)876-0426 [email protected] http://www.bcgreen.com/~samuel/ Powerful committed communication. Transformation touching the jewel within each person and bringing it to light. - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html