Re: replacing CR/LF - Mailing list pgsql-novice

From Ennio-Sr
Subject Re: replacing CR/LF
Date
Msg-id 20030712133756.GA31608@deby.ei.hnet
Whole thread Raw
In response to replacing CR/LF  ("Marcus Andree S. Magalhaes" <marcus.magalhaes@vlinfo.com.br>)
List pgsql-novice
* Marcus Andree S. Magalhaes <marcus.magalhaes@vlinfo.com.br> [110703, 22:49]:
> Hello, all.
>
> I have some data imported from some windows text files with a couple
> DOS end-of-line characters (CRLF) on it.
>
> Is there any simple way to remove them all, or just replace them with a
> single whitespace character??

Try 'dos2linux' to get rid of ^M (carriage return at end of line)
# Use: dos2linux file_dos file_unix
# Warning: if you use the same name for the two files you will loose
# your data!

Very useful can be 'tr' also:

# tr -d '\015'< $1 > $2
# tr -d '\r'< $1 > $2

# OKOKOK QUESTI COMANDI SONO UTILI:
$ tr '\n' ' ' < provosed> provosed2 # replace space to new-line
$ tr -s '\***' '\§' < provosed2> provosed3 # replaces asterisks with §
$ tr '\§' '\n' < provosed3> provosed2  # replaces § with carriage-return

I hope that helps.
Cheers,
    Ennio.
--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.     \\?//
 Fa' qualche cosa di cui non sei capace!"   (diceva Henry Miller) ]     (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that.             )=(
 Do something you aren't good at!" (used to say Henry Miller) ]

pgsql-novice by date:

Previous
From: Jeffrey Melloy
Date:
Subject: Re: Dont allow updation for few columns in a record.
Next
From: Aarni Ruuhimäki
Date:
Subject: Re: replacing CR/LF