zoukankan      html  css  js  c++  java
  • rename批量重命名文件

    用法:

    rename [选项] <表达式> <替换> <文件>...

    选项:

    • -v, --verbose explain what is being done

    • -s, --symlink act on the target of symlinks

    • -n, --no-act do not make any changes

    • -o, --no-overwrite don't overwrite existing files

    • -h, --help display this help

    • -V, --version display version

    重命名文件。

    为所有.conf加上.bak后缀

    rename '.conf' '.conf.bak' ./*.conf
    

    去掉.bak后缀

    rename '.bak' ' ' ./*.bak
    
    [02:19:54 root@C8-3-55 ~]#mkdir renameTest
    [02:20:10 root@C8-3-55 ~]#touch ./renameTest/{a..c}{1..3}.conf
    [02:20:35 root@C8-3-55 ~]#rename '.conf' '.conf.bak' ./renameTest/*.conf
    [02:21:16 root@C8-3-55 ~]#ll ./renameTest/
    总用量 0
    -rw-r--r--. 1 root root 0 3月   4 02:20 a1.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 a2.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 a3.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 b1.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 b2.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 b3.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 c1.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 c2.conf.bak
    -rw-r--r--. 1 root root 0 3月   4 02:20 c3.conf.bak
    [02:21:25 root@C8-3-55 ~]#rename '.bak' ' ' ./renameTest/*.bak
    [02:21:53 root@C8-3-55 ~]#ll ./renameTest/
    总用量 0
    -rw-r--r--. 1 root root 0 3月   4 02:20 'a1.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'a2.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'a3.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'b1.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'b2.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'b3.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'c1.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'c2.conf '
    -rw-r--r--. 1 root root 0 3月   4 02:20 'c3.conf '
    
    * * * 胖并快乐着的死肥宅 * * *
  • 相关阅读:
    黑板客爬虫闯关 代码
    新浪云SAE搭建python环境 问题拾遗
    关于python中的字符串编码理解
    linux环境中使用转义字符使命令行字符颜色高亮
    python中list作为全局变量无需global声明的原因
    获取youku视频下载链接(wireshark抓包分析)
    改变linux默认配色方案(dircolors和dircolors-solarized使用)
    限流常规设计和实例
    连接池-Mybatis源码
    Transaction-Mybatis源码
  • 原文地址:https://www.cnblogs.com/bpzblog/p/14480503.html
Copyright © 2011-2022 走看看