How to convert CR to LF in a big file?

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to convert CR to LF in a big file?
# 1  
Old 10-27-2017
How to convert CR to LF in a big file?

Hello Friends,

I have a big file that is transferred to my UNIX system and it seems it has CR as the line delimiter

When I run
Code:
file <filename> 
<filename>: ASCII text, with CR line terminators

How do I convert the file to one with LF as terminators so that my code that runs on UNIX can read it properly?

Last edited by rbatte1; 10-27-2017 at 01:11 PM.. Reason: Added CODE tags
# 2  
Old 10-27-2017
What version of Unix are you on? What is the Operating System on the originating system? How is the file being transferred?

Andrew
# 3  
Old 10-27-2017
It might be on the FTP (if that's how you move it) Setting the mode to ASCII for the transfer might help.

You might also use sed to edit the file or dos2unix if that is installed.

If you open it with vi, do you see control characters that show up as ^M It's a common enough problem.




Robin
# 4  
Old 10-27-2017
If it has CR terminators (old Apple style), you should be able to use:
Code:
tr '\r' '\n' < infile > outfile

If it has CRLF terminators (Windows style) you could use:
Code:
tr -d '\r' < infile > outfile

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to segregate a section from big file?

Hello, I need to know all IP range (ip_prefix), associated with us-west-2 region only from this link - https://ip-ranges.amazonaws.com/ip-ranges.json (it can be opened in wordpad for better visibility) Please suggest, how would I do it. If vi, awk or sed is needed, I have downloaded it on my... (7 Replies)
Discussion started by: solaris_1977
7 Replies

2. Emergency UNIX and Linux Support

Getting VALUE from Big XML File -- That's All

We got data that was supposed to be CSV, but was sent in a huge XML file. I've downloaded xmlstarlet, but I'm darned if I can get it to operate the "sel" feature to look down a path and get any sort of value. I see pieces of what should be paths, but they seem to have extraneous characters, and... (7 Replies)
Discussion started by: gmark99
7 Replies

3. Shell Programming and Scripting

parsing data from a big file using keys from another smaller file

Hi, I have 2 files format of file 1 is: a1 b2 a2 c2 d1 f3 format of file 2 is (tab delimited): a1 1.2 0.5 0.06 0.7 0.9 1 0.023 a3 0.91 0.007 0.12 0.34 0.45 1 0.7 a2 1.05 2.3 0.25 1 0.9 0.3 0.091 b1 1 5.4 0.3 9.2 0.3 0.2 0.1 b2 3 5 7 0.9 1 9 0 1 b3 0.001 1 2.3 4.6 8.9 10 0 1 0... (10 Replies)
Discussion started by: Lucky Ali
10 Replies

4. UNIX for Dummies Questions & Answers

How big is too big a config.log file?

I have a 5000 line config.log file with several "maybe" errors. Any reccomendations on finding solvable problems? (2 Replies)
Discussion started by: NeedLotsofHelp
2 Replies

5. Shell Programming and Scripting

Inserting a column from one file into another big file

Hi I have two files, one is 1.6 GB. I would like to add one extra column of information to the large file at a specific location (after its 2nd column). For example: File 1 has two columns more than 1000 rows like this MM009987 1 File 2 looks like this MM00098 MM00076 3 4 2 4 2... (1 Reply)
Discussion started by: sogi
1 Replies

6. Solaris

wtmpx file is too big

Hi, I am using Sun Solaris 5.9 OS. I have found a file called wtmpx having a size of 5.0 GB. I want to clear this file using :>/var/adm/wtmpx. My query is, would it cause any problem to the running live system. Could anyone suggest the best method to clear the file without causing problem to... (6 Replies)
Discussion started by: Vijayakumarpc
6 Replies

7. Shell Programming and Scripting

big file processeing

hi, i have a very big file that holding data, how could i pick line by line from this file. the following process can illustrate better: file ------------------- 123444444 | 122314567 |-----------data 146689000 | c=123444444 ---------- c is variable process c ... (3 Replies)
Discussion started by: omran
3 Replies

8. UNIX for Dummies Questions & Answers

How to view a big file(143M big)

1 . Thanks everyone who read the post first. 2 . I have a log file which size is 143M , I can not use vi open it .I can not use xedit open it too. How to view it ? If I want to view 200-300 ,how can I implement it 3 . Thanks (3 Replies)
Discussion started by: chenhao_no1
3 Replies
Login or Register to Ask a Question