OT: sed problem

Jez Hancock jez.hancock at munk.nu
Sat Jan 31 17:34:04 PST 2004


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.

#!/bin/sh
test="one|two|three"
set `echo "$test" | sed -e 's/\|/ /g'`

# $1="one", $2="two", $3="three":
echo $@


-- 
Jez Hancock
 - System Administrator / PHP Developer

http://munk.nu/
http://jez.hancock-family.com/  - Another FreeBSD Diary
http://ipfwstats.sf.net/        - ipfw peruser traffic logging


More information about the freebsd-questions mailing list