You are not logged in.

#1 2006-06-23 07:49:24

ivan22
Member
From: Slovakia
Registered: 2006-06-21
Posts: 19

Convert CRLF to LF

I have some files from Windows here in my NEW ArchLinux box :-) I'd like ask you, if it's possible to convert these files in one step (whole dir) to use LF at the end of line. Thank you for answer.


My Archie hardware: Screen: 29" LG 29UM58 Ultrawide - CPU: Intel Pentium G3258 - RAM: Crucial 4GB DDR3 1600MHz - HDD: ADATA Premier Pro SP900 128 GB - MB: Gigabyte H81n

Offline

#2 2006-06-23 14:09:50

gnud
Member
Registered: 2005-11-27
Posts: 182

Re: Convert CRLF to LF

windows lineendings is CRLF (rn). Remove all CR's (leaving just the LF, the uniz endline) with

tr -d 'r' < "inputfile" > "outputfile"

So, in a loop for all files in directory:

for f in *.txt
do
    tr -d'r' < "$f" > "$f"
done

This is written on windows box at work, so try it out on one file before running the loop! smile

Offline

#3 2006-06-23 19:03:51

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Convert CRLF to LF

I find this easier:

vim somefile
:set ff=unix
:wq

Offline

#4 2006-06-24 21:34:35

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: Convert CRLF to LF

extra/hd2u 1.0.0-1
    dos2unix is filter used to convert plain texts from DOS (CR/LF) format to
    UNIX format (CR) and vice versa.

Offline

Board footer

Powered by FluxBB