Created
July 3, 2012 06:18
-
-
Save editnuki/3038032 to your computer and use it in GitHub Desktop.
.txtの拡張子を持つファイルの名前を時刻にするシェルスクリプト
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 | |
TIMESTAMP=`date +"%Y%m%d%H%M"` | |
COUNT=1 | |
DIR=/home/username/test | |
cd $DIR | |
for file in * | |
do | |
if expr "$file" : ".*.txt$" > /dev/null ;then | |
mv $file $TIMESTAMP\_$COUNT.txt | |
COUNT=`expr $COUNT + 1` | |
else | |
echo $file | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if文の中で正規表現を使う参考になるかな