zoukankan      html  css  js  c++  java
  • linux批量修改文件名

    源文件;
    [root@test_machine fuzj]# ls
    fuzj-1.txt  fuzj-2.txt  fuzj-3.txt  fuzj-4.txt  fuzj-5.txt  fuzj-6.txt
    方法1.
    [root@test_machine fuzj]# for name in `ls *` ; do mv $name `echo $name| sed 's/fuzj/fuzengjie/g'` ;done
    [root@test_machine fuzj]# ls
    fuzengjie-1.txt  fuzengjie-3.txt  fuzengjie-5.txt
    fuzengjie-2.txt  fuzengjie-4.txt  fuzengjie-6.txt
    方法2.
    [root@test_machine fuzj]# for name in `ls *` ;do echo $name| awk -F"-" '{print "mv " $0 " fuzj-" $2 }'|bash ; done
    [root@test_machine fuzj]# ls
    fuzj-1.txt  fuzj-2.txt  fuzj-3.txt  fuzj-4.txt  fuzj-5.txt  fuzj-6.txt
    注意print里面的空格
    方法3.
    [root@test_machine fuzj]# for name in `ls *` ; do mv $name  ${name/fuzj/fuzengjie} ; done
    [root@test_machine fuzj]# ls
    fuzengjie-1.txt  fuzengjie-2.txt  fuzengjie-3.txt  fuzengjie-4.txt  fuzengjie-5.txt  fuzengjie-6.txt
    方法4.
    [root@test_machine fuzj]# rename fuzengjie fuzj *
    [root@test_machine fuzj]# ls
    fuzj-1.txt  fuzj-2.txt  fuzj-3.txt  fuzj-4.txt  fuzj-5.txt  fuzj-6.txt
  • 相关阅读:
    洛谷月赛 Hello World(升级版)
    codevs1001 舒适的路线
    vijos & codevs 能量项链
    vijos 运输计划
    noip2016普及组题解和心得
    UVa 10891 Game of Sum
    UVa 10635 Prince and Princess
    某模拟题题解 2016.11.17
    贪心入门题
    某模拟题题解 2016.11.16
  • 原文地址:https://www.cnblogs.com/pycode/p/8734305.html
Copyright © 2011-2022 走看看