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

Sed processes dos CR/LF in files

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

Share

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

Replace the dos control character ^ M

# IN unix ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format)

Sed's / ^ M $/ /'# in bash/tcsh, press Ctrl-V then Ctrl-M

Sed's Universe. Assumes that all lines end with CR/LF.

Sed's /\ x0DharmAccord'# gsed 3.02.80, but top script is easier

# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format

Sed "spockets" / `echo-e\ r` / "# command line under ksh

Sed's Universe'"/ `echo\ r` /" # command line under bash "

Sed "spockets / `echo\ r` /" # command line under zsh

Sed's _ gsed /\ r _

# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format

Sed "sswab" / "# method 1"

Sed-n p # method 2

# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format

# Cannot be done with DOS versions of sed. Use "tr" instead.

Tr-d\ r outfile # GNU tr version 1.22 or higher

Example: delete all blank lines and lines consisting of spaces in the file

$cat ifile | sed'/ ^ $/ d' | sed'/ ^ [[: space:]] * $/ d' # method 1

$cat ifile | sed-e'/ ^ $/ d'- e'/ ^ [[: space:]] * $/ d'# method 2

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

Servers

Wechat

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

12
Report