From owner-freebsd-questions@FreeBSD.ORG Sat Jan 31 17:27:38 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 CECEA16A4CE for ; Sat, 31 Jan 2004 17:27:38 -0800 (PST) Received: from octopus.fizon.de (housing74.bytecamp.net [212.204.60.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id E34C043D1D for ; Sat, 31 Jan 2004 17:27:34 -0800 (PST) (envelope-from rb@octopus.fizon.de) Received: from octopus.fizon.de (localhost.fizon.de [127.0.0.1]) by octopus.fizon.de (8.12.10/8.12.10) with ESMTP id i111RWVl022495; Sun, 1 Feb 2004 02:27:32 +0100 (CET) (envelope-from rb@octopus.fizon.de) Received: (from rb@localhost) by octopus.fizon.de (8.12.10/8.12.8/Submit) id i111RWsp022494; Sun, 1 Feb 2004 02:27:32 +0100 (CET) Date: Sun, 1 Feb 2004 02:27:32 +0100 From: Robert Barten To: Daniela Message-ID: <20040201012732.GA22445@octopus> References: <200402010138.44102.dgw@liwest.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200402010138.44102.dgw@liwest.at> User-Agent: Mutt/1.4.1i 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 01:27:38 -0000 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