Skip site navigation (1) Skip section navigation (2)

Re: Importing lines of variable length from ASCII

From: Andrej <andrej(dot)groups(at)gmail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Importing lines of variable length from ASCII
Date: 2010-02-25 20:35:59
Message-ID: b35603931002251235j12a86ff6gd5ccd0437b0f4fce@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
On 26 February 2010 00:52, A. Kretschmer
<andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> kretschmer(at)tux:~$ cat file.txt | awk  '{cols=split($0,a,"|"); if (cols==4) print $0; else printf ("%s|\n",$0)}'

Slightly shorter variant:
awk -F'|' '{if(NF<4){print $0"|"}else{print $0}}' file.txt



> Regards, Andreas

Cheers,
Andrej


-- 
Please don't top post, and don't use HTML e-Mail :}  Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

In response to

Responses

pgsql-novice by date

Next:From: Mary AndersonDate: 2010-02-26 01:11:41
Subject: How many columns can I have in an ORDER BY clause?
Previous:From: Andreas KretschmerDate: 2010-02-25 18:18:26
Subject: Re: Leap Years

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group