#!/bin/bash for f in $@; do #stem=`echo $f | sed 's/\(.*\.old\.\).*/\1/'` #tmus=`echo $f | sed 's/\(.*\.old\.\)\(\d*\)/\2/'` if [[ $f =~ (.*\.old\.)([0-9]+)$ ]]; then stem=${BASH_REMATCH[1]} ustm=${BASH_REMATCH[2]} sstm=`date -d @$(($ustm/1000000)) +%Y.%m.%d-%H.%M.%S` usus=`printf %06d $(($ustm%1000000))` mv $f $stem$sstm.$usus else echo skip rename file: $f fi done