Re: Postgresql and scripting

From: Jerome Lyles <susemail(at)hawaii(dot)rr(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql and scripting
Date: 2004-09-08 10:38:04
Message-ID: 200409080038.04215.susemail@hawaii.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 07 September 2004 10:22 pm, Dorward villaruz wrote:
> hi!
>
> try this in commandline i assume you save the file in sams.txt
> final file will be sams2.txt
>
> cat sams.txt | sed -e 's/ /@@/g' -e 's/ //g' -e 's/@@/ /g' > sams2.txt
>
> or put this in a script say convert.sh
>
> script start:
> #!/bin/bash
> cat $1 | sed -e 's/ /@@/g' -e 's/ //g' -e 's/@@/ /g' > $2
> script end:
>
> how to use?
>
> convert.sh <input file> <output file>
>
> best regards,
> wardy
>
Thank you for this. I've spent a few hours today searching and experimenting
to produce this code. I can almost understand the sed command. Everything
between the quotes is the action to be taken. The 's' is for substitution,
the / / is the whitespace to be replaced, the/@@/ is what the whitespace is
replaced with but I don't know what the @@ stands for, the g means it's
applied globally. I think what I just said is wrong because I have no clue
why the second and third substitution are there. And finally the output is
directed to $2. I'll have to wait until tomorrow evening to play with it. I
look forward to it.
thanks,
Jerome

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Phil Endecott 2004-09-08 11:37:30 Function caches wrong OID of temporary table?
Previous Message Jerome Lyles 2004-09-08 10:23:02 Postgresql and scripting