I am trying to check if the file is in dos format using simple grep command but the problem is lines inside the file with have special characters in between and in some lines end of the line will have the '^M' character.
I tried the below command in simple line(without special character in between the line) and it works fine but for the line which are having special characters it doesn't.
command:
cat dosfile.cnf
*AggrerMA.deo : tcp:8100^M
grep -c '^M' dosfile.cnf
output i get from above command :
0
which is wrong, since we have ^M character at the end of the line and i expect the command output to be 1
The file(1) utility will output information about the line ending style of a line and that output could easily be parsed to determine files with CRLF line endings.