Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Feb 2004 02:27:32 +0100
From:      Robert Barten <robert@barok.de>
To:        Daniela <dgw@liwest.at>
Cc:        questions@freebsd.org
Subject:   Re: OT: sed problem
Message-ID:  <20040201012732.GA22445@octopus>
In-Reply-To: <200402010138.44102.dgw@liwest.at>
References:  <200402010138.44102.dgw@liwest.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 01, 2004 at 01:38:44AM +0000, Daniela 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.

cat file | awk -F '|' '{print $1}'

you may print $2 $3 $4 ... or NF (number of fields)
-- 
Robert Barten



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040201012732.GA22445>