In Linux, the file name is converted to uppercase and lowercase in batches. A buddy called from the scene and said that there is a directory with thousands of files under it. Now, the file name must be converted from lowercase to uppercase. First, you can't write scripts. In that case, you have to teach him to use vi to change permissions. Instead, you can only use commands. Character conversion, of course, comes to mind: tr: www.2cto.com for file in *; do mv $ file 'echo $ file | tr 'a-Z' 'a-z ''; after a while, the buddy called again and said, "Do not change the extension name to uppercase. Keep it in lowercase. In this case, the obvious segmentation will certainly be handed over to awk:
For file in *; do mv $ file 'echo $ file | awk-F. '{print toupper ($1 )". "$2}''; done can modify a file similar to a.txt, but there are no more extensions, such as B .tar.gz. Fortunately, awk supports variables: www.2cto.com for file in *; do mv $ file 'echo $ file | awk-F. '{for (I = 1; I <= NF; I ++) if (I = 1) result = toupper ($ I); else result + = ". "$ I; print $ result;}''; done, but the result is wrong. The file name has not changed. Check whether gawk supports toupper and tolower, it is not correct to change to gawk. In the end, there is no way to find a compromise. First, convert all to uppercase, and then convert the extension back to lowercase: for file in *; www.2cto.com do mv $ file 'echo $ file | sed-e s /\. TXT /\. txt/G'; done \. not converted ., it still represents any character, so if basename contains an extension, it will be tragic.
After trying a few times, we found that this is the escape: sed-e s/[.] TXT/. txt/G'; OK.