Experimental material:
[[email protected] test]# ls//This directory contains all the files ending in. txt and requires all to be replaced by the. Doc End
1.txt 2.txt 3.txt 4.txt 5.txt
Writing scripts
[Email protected] test]# vim/root/25.sh
Script content:
#!/bin/bash
For I ls * .$1
in//defines the range of values for I, as long as the files ending in the file are displayed (enclosed in ls * .$1
anti-quotation marks, I don't know what the reason is, the anti-quotes are not visible)
Do
MV $i ${i%.}. $ &>/dev/null//On I perform a de-tail operation, plus a new file suffix, i%. Specify the file name of I from the. Start to remove the trailing inclusions.
Done
Give Execute permission
[Email protected] test]# chmod +x/root/25.sh
Test script:
[[email protected] test]#/root/25.sh txt doc
[[email protected] test]# ls
1.doc 2.doc 3.doc 4.doc 5.doc
Script for Shell script to bulk modify file name suffix