Created
July 25, 2018 11:20
-
-
Save xie-qianyue/83b77cd2f8de3fd4d47c13add13d1f9d to your computer and use it in GitHub Desktop.
rename the suffix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# common.lib | |
# Note no #!/bin/sh as this should not spawn | |
# an extra shell. | |
STD_MSG="About to rename some files..." | |
rename() | |
{ | |
# expects to be called as: rename .txt .bak | |
FROM=$1 | |
TO=$2 | |
for i in *$FROM # = *.txt | |
do | |
j=`basename $i $FROM` # get the basename of the file | |
mv $i ${j}$TO # ${j}$TO = someBaseName.bak | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# function.sh | |
. ./common.lib | |
echo $STD_MSG | |
rename .txt .bak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment