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