In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF). In Unix text files a line break is a single character: the Line Feed (LF).
You can use cat -A fileName to check if there is ^M$ in file, or use command set ff? in vim to read the fileformat information.
If you want to use shell script to check whether the file is dos format, you can do it in this way.

grep '^M' test.txt

^M is Ctrl-V + Ctrl-M. It will find all lines end with ^M$. If the grep returns any line, the file is in DOS format.
So we can write the command grep '^M' test.txt |wc -l to check the fileformat, the result is 0 means it’s not dos format.

You can also use file test.txt to print information to judge it.

[root@beaming-text-1 ~]# file test.txt 
test.txt: ASCII text, with CRLF line terminators
[root@beaming-text-1 ~]# file virt.log
virt-sysprep-firstboot.log: ASCII text

The relevant tool is

Categories: ShellTool

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x