Date: Mon, 16 Oct 2000 06:53:04 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Marc Wandschneider <marcw@lanfear.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: AWK trivia Message-ID: <20001016065304.A66023@gray.westgate.gr> In-Reply-To: <000701c036d4$d6578340$0800000a@lanfear.com>; from marcw@lanfear.com on Sun, Oct 15, 2000 at 08:22:07PM %2B0200 References: <000701c036d4$d6578340$0800000a@lanfear.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
<off the top of my head awk & sed games>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001016065304.A66023>
