In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail about using the dos2unix command in linux to convert DOS format text files into UNIX format, Xiaobian thinks it is very practical, so share it for you to do a reference, I hope you can get something after reading this article.
The dos2unix command is used to convert text files in DOS format to UNIX format (DOS/MAC to UNIX text file format converter). The text file under DOS is marked with\ r\ nas a line breaker, which is 0D 0A in hexadecimal. The text file under Unix uses\ nas the line break flag, which is 0A in hexadecimal.
Text files in DOS format display ^ M at the end of the line when opened with an earlier version of vi under Linux, and many commands do not handle files in this format very well. If it is a shell script, the text file in Unix format will be pieced together when opened with Notepad under Windows. Therefore, there is a need to convert the two format files to each other, and the corresponding unix2dos command is to convert the UNIX format text file to DOS format.
Syntax format: dos2unix [parameters] [file]
Common parameters:
-k keep the date of the output file unchanged-Q quiet mode, without prompting any warning-V view version-c conversion mode: ASCII 7bit ISO Mac-o writes to source file-n writes to new file
Reference example
The simplest use is for dos2unix to follow the file name directly:
[root@linuxcool ~] # dos2unix file
If you convert more than one file at a time, follow the file names directly after dos2unix. (note: you can add the-o parameter or not, and the effect is the same.)
[root@linuxcool ~] # dos2unix file1 file2 file3 [root@linuxcool ~] # dos2unix-o file1 file2 file3
The above conversion will be directly modified on the original file, if you want to save the results of the conversion in another file, but the source file remains unchanged, you can use the-n parameter.
[root@linuxcool ~] # dos2unix-n oldfile newfile
If you want to keep the file timestamp unchanged, add the-k parameter. So the above commands can be added with the-k parameter to maintain the file timestamp.
[root@linuxcool ~] # dos2unix-k file [root@linuxcool ~] # dos2unix-k file1 file2 file3 [root@linuxcool ~] # dos2unix-k-o file1 file2 file3 [root@linuxcool ~] # dos2unix-k-n oldfile newfile about using the dos2unix command in linux to convert DOS format text files into UNIX format is shared here. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.