zoukankan      html  css  js  c++  java
  • 根据已有目录结构从目标目录中提取

    echo $#
    if [ $# -lt 2 ]; then
        echo "input basis folder base:"
        read src
        echo "input target folder base:"
        read target
        echo "input output folder base:"
        read output
    else
        src=$1
        target=$2
        output=$3
    fi
    echo "input param: "$src" "$target" "$output
    if [ ! -d "$src" ]; then
        echo "invalid src folder"
        exit 1
    fi
    if [ ! -d "$target" ]; then
        echo "invalid target folder"
        exit 2
    fi
    if [ ! -d "$output" ]; then
        mkdir -p "$output"
    fi
    
    function extract(){
        targetFile=${1#*/}
        targetFile=${targetFile#*/}
    #    echo "coping "$targetFile"  to "$output"/"$targetFile
        if [ -f $target"/"$targetFile ]; then    
    #    echo "coping "$target"/"$targetFile"  to "$output"/"$targetFile
        cp --preserve $target"/"$targetFile $output"/"$targetFile
        fi    
    }
    function extractFolder(){
        targetFile=${1#*/}
        targetFile=${targetFile#*/}
    #    echo "coping "$targetFile"  to "$output"/"$targetFile
        if [ -d $target"/"$targetFile ]; then    
        echo "creating folder "$target"/"$targetFile"  to "$output"/"$targetFile
        mkdir -p $output"/"$targetFile
        fi    
    }
    
    function read_dir(){
    for file in `ls $1` 
    do
     if [ -d $1"/"$file ] 
     then
     extractFolder $1"/"$file
     read_dir $1"/"$file
     else
     #echo "dealing file  "$1"/"$file 
     extract $1"/"$file 
     fi
    done
    } 
    read_dir $src

    ./extract.sh ./BuildRoot ./b7r6 ./output

  • 相关阅读:
    更改桌面位置
    三国杀高级技巧!!
    excel中删除空白行方法
    欢迎来稿
    coreseek配置文件分析
    html中a连接触发表单提交
    html点击按钮动态添加input文本框
    页面表单预览数据传递注意事项
    mysql 主从复制(masterslave)
    mysql explain key_len小结
  • 原文地址:https://www.cnblogs.com/wolbo/p/13810295.html
Copyright © 2011-2022 走看看