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 '
    
    * * * 胖并快乐着的死肥宅 * * *
  • 相关阅读:
    c++ 内存管理
    socket粘包现象加解决办法
    TCP与UDP比较 以及并发编程基础知识
    进程之 Process join方法其他属性与进程Queue
    socket通讯实例与TCP/UDP的区别
    socket介绍
    python中的异常处理机制
    面向对象之多态,多态性,反射,以及基于反射的可拔插设计
    面向对象之元类介绍
    面向对象基础
  • 原文地址:https://www.cnblogs.com/bpzblog/p/14480503.html
Copyright © 2011-2022 走看看