【linux】Linux批量更改文件后缀名

内容来源于:https://www.cnblogs.com/nkwy2012/p/6362207.html

 

一.rename解决

1.  Ubuntu系统下

rename 's//.c//.h/'  ./*

把当前目录下的后缀名为.c的文件更改为.h的文件

2.  CentOS5.5系统下

rename .c  .h   *.c

把当前目录下的后缀名为.c的文件更改为.h的文件

 

二.shell 脚本解决

#!/bin/bash

#http://blog.csdn.NET/longxibendi
find ./ -name *.c  | while read i
do
        echo "$i";
        mv $i.c  $i.h
done

   

三.find  xargs 解决

 find ./ -name "*.c" | awk -F "." '{print $2}' | xargs -i -t mv ./{}.c  ./{}.h

  

posted @ 2019-06-28 16:13  望着小月亮  阅读(4258)  评论(0编辑  收藏  举报