Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Linux dos2unix command

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "how to use the Linux dos2unix command", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use the Linux dos2unix command" can help you solve your doubts.

Linux commonly used command dos2unix is used to convert text files in DOS format to UNIX format (DOS/MAC to UNIX text file format converter).

Dos2unix converts DOS format text files to Unix format

Add that 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 are under Linux, and ^ M appears at the end of the line when opened with an earlier version of vi, and many commands do not handle this format very well, if it is a shell script. On the other hand, text files in Unix format will be displayed 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 dos2unix [- hkqV] [- c convmode] [- o file...] [- n infile outfile...] Option-k: keep the date of the output file unchanged-Q: quiet mode without prompting any warnings. -V: view version-c: conversion pattern. Patterns are: ASCII, 7bit, ISO, Mac. Default is: ASCII. -o: write to source file-n: write to new file parameter parameter: need to convert to file.

The simplest use of an example is to follow the file name directly with dos2unix:

If dos2unix file converts 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.)

Dos2unix file1 file2 file3 dos2unix-o file1 file2 file3 above in the 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.

Dos2unix 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.

Dos2unix-k file dos2unix-k file1 file2 file3 dos2unix-k-o file1 file2 file3 dos2unix-k-n oldfile newfile converts all files in the current directory

Find-type f | xargs dos2unix has finished the introduction of this article "how to use the Linux dos2unix command". If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about related articles, please follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report