您的位置:首页 > 其它

Ubuntu删除两个文件夹下同名同内容的文件V1.2

2017-07-13 21:18 645 查看
http://blog.csdn.net/u010555688/article/details/51280783

Ubuntu删除两个文件夹下同名同内容的文件

参考:http://bbs.chinaunix.net/forum.PHP?mod=viewthread&tid=1851432&page=1

缘起:一直在维护android的BSP,有时候发现另外一个来源的BSP有你所需要的一些功能。

因此需要有一个工具,比对两份代码,将两份BSP里面的相同文件名(内容也完全相同)的文件删除掉。

1、列出两个文件夹dir1、dir2下相同的文件:

(英文版本ubuntu)

diff -rs dir1 dir2|grep 'identical$'  

(中文版本ubuntu)

rootroot@rootroot-E400:~$ cd wyb/

rootroot@rootroot-E400:~/wyb$ cd diff/

rootroot@rootroot-E400:~/wyb/diff$ diff -rs rtl8188eu4a/ rtl8188eu6a/  | grep "相同$" > 3.txt

2、删除同名同内容的文件(只需要执行一次):

awk '{print $2}' 3.txt | xargs rm -rf

awk '{print $4}' 3.txt | xargs rm -rf

find r58_20160823/ -name "*" -type d -empty | xargs rm -rf

find r58_evb_sc5806/ -name "*" -type d -empty | xargs rm -rf
http://bbs.csdn.net/topics/320031351
awk如何删除一个文件?

3、工作基本上做完了,但是会出现很多空目录:
http://www.111cn.net/sys/linux/46433.htm
linux中find批量删除空文件及空文件夹脚本

(需要多执行几次,有些目录里面只有空目录!!!!)

find -type d -empty | xargs rm -rf

find . -name "*" -type d -empty | xargs rm -rf

rootroot@rootroot-E400:~/wyb/diff$ find -type d -empty

./rtl8188eu4a/os_dep/linux

./rtl8188eu4a/include/byteorder

./rtl8188eu4a/include/linux

./rtl8188eu4a/core/efuse

./rtl8188eu4a/hal/hal_hci

./rtl8188eu4a/hal/OUTSRC-BTCoexist

./rtl8188eu4a/hal/OUTSRC/rtl8188e

./rtl8188eu4a/hal/led

./rtl8188eu4a/hal/rtl8188e/usb

./rtl8188eu6a/os_dep/linux

./rtl8188eu6a/include/byteorder

./rtl8188eu6a/include/linux

./rtl8188eu6a/core/efuse

./rtl8188eu6a/hal/hal_hci

./rtl8188eu6a/hal/OUTSRC-BTCoexist

./rtl8188eu6a/hal/OUTSRC/rtl8188e

./rtl8188eu6a/hal/led

./rtl8188eu6a/hal/rtl8188e/usb

rootroot@rootroot-E400:~/wyb/diff$ find . -name "*" -type d -empty

./rtl8188eu4a/os_dep/linux

./rtl8188eu4a/include/byteorder

./rtl8188eu4a/include/linux

./rtl8188eu4a/core/efuse

./rtl8188eu4a/hal/hal_hci

./rtl8188eu4a/hal/OUTSRC-BTCoexist

./rtl8188eu4a/hal/OUTSRC/rtl8188e

./rtl8188eu4a/hal/led

./rtl8188eu4a/hal/rtl8188e/usb

./rtl8188eu6a/os_dep/linux

./rtl8188eu6a/include/byteorder

./rtl8188eu6a/include/linux

./rtl8188eu6a/core/efuse

./rtl8188eu6a/hal/hal_hci

./rtl8188eu6a/hal/OUTSRC-BTCoexist

./rtl8188eu6a/hal/OUTSRC/rtl8188e

./rtl8188eu6a/hal/led

./rtl8188eu6a/hal/rtl8188e/usb

rootroot@rootroot-E400:~/wyb/diff$ 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐