From owner-freebsd-questions@FreeBSD.ORG Sun Feb 1 06:40:03 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49D9C16A4CE for ; Sun, 1 Feb 2004 06:40:03 -0800 (PST) Received: from lilzmailso02.liwest.at (lilzmailso02.liwest.at [212.33.55.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE6DF43D53 for ; Sun, 1 Feb 2004 06:39:55 -0800 (PST) (envelope-from dgw@liwest.at) Received: from cm58-27.liwest.at ([212.33.58.27]) by lilzmailso02.liwest.at with esmtp (Exim 4.24) id 1AnIlO-0004gX-VT; Sun, 01 Feb 2004 15:39:55 +0100 From: Daniela To: Jez Hancock Date: Sun, 1 Feb 2004 15:33:58 +0000 User-Agent: KMail/1.5.3 References: <200402010138.44102.dgw@liwest.at> <20040201013401.GA35376@users.munk.nu> In-Reply-To: <20040201013401.GA35376@users.munk.nu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402011533.58877.dgw@liwest.at> cc: questions@freebsd.org Subject: Re: OT: sed problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Feb 2004 14:40:03 -0000 On Sunday 01 February 2004 01:34, Jez Hancock wrote: > 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 $@ This doesn't work when the parts between the pipe characters contain spaces themselves.