I'm trying to find all modules that contain line feed characters. It shows up at ^M (Hex 0D0A). Does anyone know how to do a search for hex fields?
I tried doing "egrep ^M *.cbl", but that doesn't work.
Thanks!
I'm trying to find all modules that contain line feed characters. It shows up at ^M (Hex 0D0A). Does anyone know how to do a search for hex fields?
I tried doing "egrep ^M *.cbl", but that doesn't work.
Thanks!
Try this, type ^M as <Ctrl>-V <Enter>:
grep '^M' *.cbl
Hex 0D0A is two characters : Carriage Return and Line Feed .
This is the Microsoft MSDOS line terminator for text files.
The unix terminator for text files is just Line Feed (Hex 0A).
If you have text files on your unix box with a Microsoft line terminator they have probably been copied with ftp in binary mode (rather than ascii mode) or come from alien media.
Most unixes come with the "dos2ux" or "dos2unix" conversion program but this can affect foreign character sets.
To just remove Carriage Return characters.
cat oldfile.txt | tr -d "\r" > newfile.txt
To find the names of your files containing Carriage Return characters.
#!/bin/ksh
CR=`echo "\0015\c"`
grep -l "${CR}" *.cbl
Thanks very much! Both of your suggestions did exactly what I was looking for.