linux下shell脚本移动、复制文件笔记

#!/bin/bash
function jarmv(){
    for file in ` ls $1`
    do
        if [ -d $1"/"$file ] #如果 file存在且是一个目录则为真
        then
              jarmv $1"/"$file
        else
            jarpath=$1"/"$file
            reg=.*jar
            if [[ \"$jarpath\" =~ $reg ]];    then
                echo $jarpath
                sudo mv $jarpath "/home/dragon/workspace/scala/jar"
            fi
        fi

    done
}
INIT_PATH="/home/dragon/workspace/scala/deeplearning4j"
jarmv $INIT_PATH 
#!/bin/bash
function copy(){
        for file in ` ls $1`
        do
                if [ -f $1"/"$file ] #
                then
                        copy_path=$1"/"$file
                        if echo $file|grep .*nc
                        then
                                echo $copy_path
                                sudo mv  $copy_path "/home/..."


                        fi
                fi

        done
}
INIT_PATH="/home/..."
copy $INIT_PATH

你可能感兴趣的:(Linux)