The following script allows you to convert directories or file uppercase and lowercase letters as follows:
Copy Code code as follows:
#!/bin/sh
#edit by Www.jb51.net
# [: Upper:] [A-z]
# [: Lower:] [A-z]
# [:d igit:] [0-9]
# [: Alnum:] [0-9 A-z]
# [: Space:] spaces or t a b keys
# [: Alpha:] [A-A-z]
# TR
For f in *
Todo
echo $f | TR "[: Upper:]" [: Lower:] "
Done
#awk
#把当前目录下的所有小写文件名都改为大写文件名.
ls | awk ' {printf ("mv%s%s\n", $, ToUpper ($)) | " SH "}"
#把当前目录下的所有大写文件名都改为小写文件名.
ls | awk ' {printf ("mv%s%s\n", $, ToLower ($)) | " SH "}"
#sed
File= "Test.txt"
Cat $file | Sed ' y/abcdefghijklmnopqrstuvwxyz/abcdefghijklmnopqrstuvwxyz/'
Code Description:
Method 1, using the TR command.
Method 2, Method 3, using the AW command.
Method 4, using the cat sed command.
For the test file Test.txt, its original content, as shown in the following figure:
By Method 4, the contents of the conversion are all capitalized, as shown in the following figure: