Operating System - HP-UX
1827295 Members
1580 Online
109960 Solutions
New Discussion

Re: CTRL-K in text files - How to Delete or expand to CR/LF?

 
SOLVED
Go to solution
Alzhy
Honored Contributor

CTRL-K in text files - How to Delete or expand to CR/LF?

I have a large CSV file from a Filemaker DB. One field contains ersthwhile RICH formatted text data. I notice the file when VI'd have "^k" all throughout which is representative of Carriage Returns.

How do I remove or replace them so they expand to CR/LF in UNIX?
Hakuna Matata.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: CTRL-K in text files - How to Delete or expand to CR/LF?

In UNIX, you do not want a CR/LF pair, you simply want a LF (Octal 012). We simply need to use tr to replace your Control-K's (Octal 013) with LF's.

tr "[\013]" "[\012]" < infile > outfile
If it ain't broke, I can fix that.
Alzhy
Honored Contributor

Re: CTRL-K in text files - How to Delete or expand to CR/LF?

A. Clay - if you're in my neck of the woods right now, I'll buy you a tall glass of Kirin Lager.

Man you hit it.. I was as well close after I did an "od -c file" and noticed those ^Ks are actually CHR 013's.

Many many thanks!
Hakuna Matata.
Alzhy
Honored Contributor

Re: CTRL-K in text files - How to Delete or expand to CR/LF?

I was also earlier trying dos2ux (reverse of ux2dos) but to no avail.

Thanks for the tr tip once more!
Hakuna Matata.