Обсуждение: replacing CR/LF

Поиск
Список
Период
Сортировка

replacing CR/LF

От
"Marcus Andree S. Magalhaes"
Дата:
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??

thanks.



-------------------------------
   http://www.vlinfo.com.br

Re: replacing CR/LF

От
Ennio-Sr
Дата:
* 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) ]

Re: replacing CR/LF

От
Aarni Ruuhimäki
Дата:
Hi !

pico should remove those as well as MS _M ? Open --> space --> backspace -->
Save

BR,

Aarni

On Saturday 12 July 2003 01:49, you wrote:
> 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??
>
> thanks.
>
>
>
> -------------------------------
>    http://www.vlinfo.com.br
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
Aarni Ruuhimäki
Megative Tmi
KYMI.com

Pääsintie 26
45100 Kouvola
FINLAND

info@kymi.com / aarni.ruuhimaki@kymi.com

+358-5-3755 035 / +358-50-4910 037
---------------------------------------------------------
Linux RedHat / KDE / PostgreSQL database power
---------------------------------------------------------



Re: replacing CR/LF

От
"Rudi Starcevic"
Дата:
Hi Marcus,

Yes there is a simple way to fix this.

Many times I've had to export text from windows text files.
Here's how I do it.

After moving the text files onto Linux use this command to
clear up the offending character(s)

cat file.txt | perl -pe 's:\r::g' > file2.txt

Inside file2.txt all the \r have been replaced with nothing.

Lets say now you then need to clean up some pesky $ as well.

Just press the up arrow on your keyboard to bring up the command's
you just executed and edit them a little to look like this:

cat file2.txt | perl -pe 's:\$::g' > file3.txt

As you can see these commands can be handy to clean up all sort's
of characters.

Hope this helps.

Cheers
Rudi.





> 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??
>
> thanks.
>
> -------------------------------
>    http://www.vlinfo.com.br
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org