From owner-freebsd-questions Sun Oct 15 20:53:21 2000 Delivered-To: freebsd-questions@freebsd.org Received: from gray.westgate.gr (gray.westgate.gr [212.205.119.66]) by hub.freebsd.org (Postfix) with ESMTP id 6EC9037B503 for ; Sun, 15 Oct 2000 20:53:16 -0700 (PDT) Received: (from charon@localhost) by gray.westgate.gr (8.11.1/8.11.1) id e9G3r4p67266; Mon, 16 Oct 2000 06:53:04 +0300 (EEST) Date: Mon, 16 Oct 2000 06:53:04 +0300 From: Giorgos Keramidas To: Marc Wandschneider Cc: freebsd-questions@FreeBSD.ORG Subject: Re: AWK trivia Message-ID: <20001016065304.A66023@gray.westgate.gr> References: <000701c036d4$d6578340$0800000a@lanfear.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <000701c036d4$d6578340$0800000a@lanfear.com>; from marcw@lanfear.com on Sun, Oct 15, 2000 at 08:22:07PM +0200 X-PGP-Fingerprint: 3A 75 52 EB F1 58 56 0D - C5 B8 21 B6 1B 5E 4A C2 X-URL: http://students.ceid.upatras.gr/~keramida/index.html Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Oct 15, 2000 at 08:22:07PM +0200, Marc Wandschneider wrote: > > so, i have a file in the following format: > > SOME_SINGLE_WORD STRING "A quoted String" > > Where the two things are separated by any amount of whitespace, not > including \n. I would try something like: % sed -e 's/[ ^I]*/:/' to make the first part of the line (the one including SOME_SINGLE_WORD_STRING, in your example) be separated from the rest of the line by a single ':' character. Then it should be fairly easy to have AWK print what you want. % cat format.awk { printf "$1 = %s\n", $1; printf "$2 = "; for (i = 2; i < NF; i++) { printf "%s%s", $i, FS; } printf "%s\n", $NF; } and fire up awk with something like: % sed -e 's/[ ^I]*/:/' | awk -f format.awk -F: Ciao, Giorgos. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message