Link to home
Start Free TrialLog in
Avatar of Anthony Mellor
Anthony MellorFlag for United Kingdom of Great Britain and Northern Ireland

asked on

AWK How to eradicate Windows carriage returns from 52 files now on unix/mac?

7 CSV FILES
9 tab files
36 dat files

and of course I'm not sure what the delimiter is in the dats and tab files.
I guess I have to hex view and see.

So an awk question with multiple delimiters: or, process each group separately.

The hex codes of the Windows line eols or carriage returns are 0d0a .
Doing one file isn't the issue, it's doing all 54.

I will hex view now and see if i can spot the delimiters in the tabs and dats.

I found this code but it's Greek to me.

awk 'gsub(/\r/,""){printf $0;next}{print}'

Open in new window

Avatar of Bill Prew
Bill Prew

How do you "move" the files from Windows to the Mac?

Easy enough to massage the data with a small VBS script, I have some samples that do things like this I can provide, but I would suggest you post a few different sample files here (if possible) so that I can view and look for what needs to be changed.

~bp
ASKER CERTIFIED SOLUTION
Avatar of Colin_UK
Colin_UK
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Mellor

ASKER

installed dos2unix, successful command to convert all files in directory/folder

dos2unix *.*

proof of the pudding:

MacPro:Original Data ADM$ dos2unix *.*
dos2unix: converting file DfTRoadSafety_Accidents_2005.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2006.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2007.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2008.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2009.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2010.csv to Unix format...
dos2unix: converting file DfTRoadSafety_Accidents_2011.csv to Unix format...
dos2unix: converting file acc00.tab to Unix format...
dos2unix: converting file acc01.tab to Unix format...
dos2unix: converting file acc02.tab to Unix format...
dos2unix: converting file acc03.tab to Unix format...
dos2unix: converting file acc04.tab to Unix format...
dos2unix: converting file acc87.tab to Unix format...
dos2unix: converting file acc88.tab to Unix format...
dos2unix: converting file acc89.tab to Unix format...
dos2unix: converting file acc90.tab to Unix format...
dos2unix: converting file acc91_a.dat to Unix format...
dos2unix: converting file acc91_b.dat to Unix format...
dos2unix: converting file acc91_c.dat to Unix format...
dos2unix: converting file acc91_d.dat to Unix format...
dos2unix: converting file acc92_a.dat to Unix format...
dos2unix: converting file acc92_b.dat to Unix format...
dos2unix: converting file acc92_c.dat to Unix format...
dos2unix: converting file acc92_d.dat to Unix format...
dos2unix: converting file acc93_a.dat to Unix format...
dos2unix: converting file acc93_b.dat to Unix format...
dos2unix: converting file acc93_c.dat to Unix format...
dos2unix: converting file acc93_d.dat to Unix format...
dos2unix: converting file acc94_a.dat to Unix format...
dos2unix: converting file acc94_b.dat to Unix format...
dos2unix: converting file acc94_c.dat to Unix format...
dos2unix: converting file acc94_d.dat to Unix format...
dos2unix: converting file acc95_a.dat to Unix format...
dos2unix: converting file acc95_b.dat to Unix format...
dos2unix: converting file acc95_c.dat to Unix format...
dos2unix: converting file acc95_d.dat to Unix format...
dos2unix: converting file acc96_a.dat to Unix format...
dos2unix: converting file acc96_b.dat to Unix format...
dos2unix: converting file acc96_c.dat to Unix format...
dos2unix: converting file acc96_d.dat to Unix format...
dos2unix: converting file acc97_a.dat to Unix format...
dos2unix: converting file acc97_b.dat to Unix format...
dos2unix: converting file acc97_c.dat to Unix format...
dos2unix: converting file acc97_d.dat to Unix format...
dos2unix: converting file acc98_a.dat to Unix format...
dos2unix: converting file acc98_b.dat to Unix format...
dos2unix: converting file acc98_c.dat to Unix format...
dos2unix: converting file acc98_d.dat to Unix format...
dos2unix: converting file acc99_a.dat to Unix format...
dos2unix: converting file acc99_b.dat to Unix format...
dos2unix: converting file acc99_c.dat to Unix format...
dos2unix: converting file acc99_d.dat to Unix format...
MacPro:Original Data ADM$

took the time it took to write this post. About 600 mb of text files.

[embed=file 1148430]
acc03_txt_and_-acc02_txt.jpg
Bill, by email and dropbox variously.