遍历当前路径下目录并移动shell脚本

#!/bin/bash
str="scm_image"
function mvfile(){
    for file in `ls $1`
    do 
       if [ -d $1"/"$file ]
       then
	    if [ $file != $str ]
	    then
		len=${#str}
		substr=${file:$len}
		echo $substr
		mv $file ./scm_image/$substr
	    fi
       fi
    done
}

runPath=$(cd `dirname $0`;pwd)
mvfile $runPath

你可能感兴趣的:(linux&shell)