Welcome 微信登录

首页 / 操作系统 / Linux / find结合rename实现批量修改后缀

记得曾经去腾讯面试运维的职位时,笔试中就有这么道题:要求查找/tmp下以.sh为后缀的文件并将所有这些文件修改为.bash后缀。其实很简单,一个命令可以实现:# rename .sh .bash *.sh上面这个命令是将当前目录下的所有.sh文件修改为.bash做后缀。首先要确保这个命令所在的软件包安装了,[jeff@rhel55 mydir]$ rpm -qif `which rename`
Name        : util-linux                  Relocations: (not relocatable)
Version    : 2.13                              Vendor: Red Hat, Inc.
Release    : 0.52.el5_4.1                  Build Date: Thu 07 Jan 2010 06:25:25 PM CST
Install Date: Thu 02 Feb 2012 06:49:04 PM CST      Build Host: x86-007.build.bos.RedHat.com
Group      : System Environment/Base      Source RPM: util-linux-2.13-0.52.el5_4.1.src.rpm
Size        : 4706614                          License: distributable
Signature  : DSA/SHA1, Wed 13 Jan 2010 05:19:06 PM CST, Key ID 5326810137017186
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary    : A collection of basic system utilities.
Description :
The util-linux package contains a large variety of low-level system
utilities that are necessary for a Linux system to function. Among
others, Util-linux contains the fdisk configuration tool and the login
program.那么配合find就更省事了,# find /tmp -name "*.sh" -exec rename .sh .bash {} ;HP-UX 11.31硬件路径详解CentOS-6.3-x86_64自定义镜像制作过程相关资讯      Find  rename 
  • Linxu命令与文件的搜索 - which,  (08/03/2015 09:30:37)
  • Linux下查找文件find命令  (10/28/2014 20:11:29)
  • 文本查找利器find的使用  (03/03/2014 09:20:35)
  • Linux基础教程:find 与 xargs  (04/05/2015 10:20:11)
  • find、xargs命令使用及方法详解  (03/07/2014 17:49:41)
  • 功能强大的find命令  (01/15/2014 15:03:36)
本文评论 查看全部评论 (0)
表情: 姓名: 字数