Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jan 2004 19:58:25 -0500
From:      Marty Landman <MLandman@face2interface.com>
To:        Daniela <dgw@liwest.at>, questions@freebsd.org
Subject:   Re: OT: sed problem
Message-ID:  <6.0.0.22.0.20040131195217.01b138d8@pop.face2interface.com>
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
At 08:38 PM 1/31/2004, Daniela wrote:
>I was wondering how I can do the following with sed (or another program):

How's Perl, Daniela?

>1. Output only the text from the start of the line to the first pipe character

$out = ($line =~ /^([^\|]+)/);

>2. Output only the text between the last and the previous pipe character

$out = ($line =~ /\|([^\|]+)|/);

>Or, split the line at the pipe characters and assign the parts to 
>different shell variables.

my @ary = split '|', $line;

These are untested but probably pretty close at least. Sorry, I haven't 
gotten to shell scripting yet so I think in terms of Perl.

Marty Landman   Face 2 Interface Inc 845-679-9387
This Month's New Quiz --- Past Superbowl Winners
Make a Website: http://face2interface.com/Home/Demo.shtml



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