On Sun, 1 Feb 2004 01:38:44 +0000
Daniela <[EMAIL PROTECTED]> wrote:

> I was wondering how I can do the following with sed (or another
> program): 1. Output only the text from the start of the line to the
> first pipe character 2. Output only the text between the last and the
> previous pipe character Or, split the line at the pipe characters and
> assign the parts to different shell variables.

It sounds like awk might be better suited to what you want to do than

You should be able to do something like this with sh and awk:

        cat test.txt | awk -F'|' '{ print $1,$2,$3 }' | \
        while read VAR1 VAR2 VAR3; do
               # do something with $VAR1, $VAR2, and $VAR3

So if test.txt contains


On the first iteration of the while loop, VAR1=a, VAR2=b, and VAR3=c,
and on the second iteration... well, you get the idea :)

[EMAIL PROTECTED] mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to