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 realize letter conversion by shell in linux

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

Share

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

The purpose of this article is to share with you about how shell converts letters in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

#! / bin/sh

#

# [: upper:] [A-Z]

# [: lower:] [a-z]

# [: digit:] [0-9]

# [: alnum:] [0-9 a-z Amurz]

# [: space:] Space or t a b key

# [: alpha:] [a-z A-Z]

#

# sed

Cat file | sed-I'ybind abcdefghijklmnopqrstuvwxyz @ ABCDEFGHIJKLMNOPQRSTUVWXYZ

# tr

For f in *

Do

Mv $f `echo $f | tr "[: upper:]"[: lower:]" `

Done

# awk

# change all lowercase file names in the current directory to uppercase file names.

Ls | awk'{printf ("mv% s% s\ n", $0, toupper ($0)) | "sh"}'

# change all uppercase file names in the current directory to lowercase file names.

Ls | awk'{printf ("mv% s% s\ n", $0, tolower ($0)) | "sh"}'

#

${string/substring/replacement} use $replacement instead of the first matching $substring

${string//substring/replacement} use $replacement instead of all matching $substring

Thank you for reading! This is the end of this article on "how to achieve letter conversion in shell in linux". I hope the above content can be of some help to you, so that you can 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.

Share To

Servers

Wechat

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

12
Report