shell编程:经典shell代码

1.shell批量去掉文件后缀,批量重命名。html

#移除文件的.ok后缀,须要传入一个参数,为须要查找ok文件的路径
function mvok() {
    if [ $# -eq 1 ] ;then
        for file in `hdfs dfs -find $1 -name "*.ok"`
        do
            echo "move ok on file ${file}"
            hdfs dfs -mv ${file} ${file%.ok}
        done
    fi
}linux

批量修改文件后缀,注意${file%.ok}是指从file从后找.ok,有的话就去掉shell

linux shell 字符串操做(长度,查找,替换)详解spa

相关文章
相关标签/搜索