Re: Importing lines of variable length from ASCII - Mailing list pgsql-novice

From Andrej
Subject Re: Importing lines of variable length from ASCII
Date
Msg-id b35603931002251235j12a86ff6gd5ccd0437b0f4fce@mail.gmail.com
Whole thread Raw
In response to Re: Importing lines of variable length from ASCII  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Responses Re: Importing lines of variable length from ASCII
Re: Importing lines of variable length from ASCII
List pgsql-novice
On 26 February 2010 00:52, A. Kretschmer
<andreas.kretschmer@schollglas.com> wrote:
> kretschmer@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

pgsql-novice by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: Leap Years
Next
From: Mary Anderson
Date:
Subject: How many columns can I have in an ORDER BY clause?