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 '
    
    * * * 胖并快乐着的死肥宅 * * *
  • 相关阅读:
    Iterator 迭代器
    Collection-List
    Collection-Set
    Collection
    多线程
    面向对象<高级>知识点
    链表
    面向对象<基础>知识点
    三层架构和MVC模式详解
    impala为什么比hive快
  • 原文地址:https://www.cnblogs.com/bpzblog/p/14480503.html
Copyright © 2011-2022 走看看