Created
July 4, 2012 04:56
-
-
Save editnuki/3045426 to your computer and use it in GitHub Desktop.
引数のファイルをリネームするシェルスクリプト
This file contains hidden or 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/bash | |
#ファイル名のtestという文字列をhogeに変更するスクリプト | |
NAME=$1 | |
NAME_AFTER=$2 | |
shift 2 | |
for FILE in $@;do | |
[[ -e "$FILE" ]] || { echo "$FILE file didn't exist" ; exit 1 ; } | |
RENAME=`echo $FILE | sed "s/$NAME/$NAME_AFTER/g"` | |
mv $FILE $RENAME | |
done | |
echo "file rename ok" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment