2017/5/2 17:09
缘起:一直在维护android的BSP,有时候发现另外一个来源的BSP有你所需要的一些功能。
因此需要使用一个工具,比对两份代码,将两份BSP里面的相同文件名(内容也完全相同)的文件删除掉。
(英文版本ubuntu)
diff -rs dir1 dir2 | grep 'identical$'
(中文版本ubuntu)
rootroot@cm-System-Product-Name:/home/wwt$ diff -rs prk_tina_bak/ fds_tinav2.1/ | grep "相同$" > 3.txt
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ rm .repo/ -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ cd ../prk_tina_bak/
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ rm .repo/ -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$
rootroot@cm-System-Product-Name:/home/wwt$ cd prk_tina_bak/
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name .git
./target/.git
./dl/.git
./scripts/.git
./toolchain/.git
./lichee/brandy/.git
./lichee/linux-3.4/.git
./.repo/manifests/.git
./.repo/repo/.git
./tools/.git
./package/.git
./config/.git
./prebuilt/.git
./docs/.git
./build/.git
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name .git | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name .git
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ cd ../fds_tinav2.1/
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name .git
./target/.git
./dl/.git
./scripts/.git
./toolchain/.git
./lichee/brandy/.git
./lichee/linux-3.4/.git
./.repo/manifests/.git
./.repo/repo/.git
./tools/.git
./package/.git
./config/.git
./prebuilt/.git
./docs/.git
./build/.git
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name .git | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name .git
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$
正式使用diff比对,将不同的部分存储到文件:3.txt
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ cd ..
rootroot@cm-System-Product-Name:/home/wwt$ diff -rs prk_tina_bak/ fds_tinav2.1/ | grep "相同$" > 3.txt
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib64/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib64/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux/lib64/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib64/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib64/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/aarch64-openwrt-linux-musl/lib64/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib32/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib32/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib32/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib64/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib64/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/aarch64/toolchain-sunxi/toolchain/lib64/lib64: recursive directory loop
diff: prk_tina_bak/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/arm-openwrt-linux/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/arm-openwrt-linux/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/arm-openwrt-linux-muslgnueabi/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/arm-openwrt-linux-muslgnueabi/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib32/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib32/lib: 符号连接的层数过多
diff: prk_tina_bak/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib64/lib: 符号连接的层数过多
diff: fds_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib64/lib: 符号连接的层数过多
rootroot@cm-System-Product-Name:/home/wwt$
awk '{print $2}' 3.txt | xargs rm -rf
awk '{print $4}' 3.txt | xargs rm -rf
参考资料:
http://bbs.csdn.net/topics/320031351
awk -F,'{print $2}' test.txt | xargs rm -rf
由于有些空文件夹里面只有空文件夹,当你删除最底层的空文件夹,上层的文件夹也是空的。
因此需要多次执行!
rootroot@cm-System-Product-Name:/home/wwt$ cd prk_tina_bak/
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ find . -name "*" -type d -empty
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$
rootroot@cm-System-Product-Name:/home/wwt/prk_tina_bak$ cd ../fds_tinav2.1/
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty | xargs rm -rf
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$ find . -name "*" -type d -empty
rootroot@cm-System-Product-Name:/home/wwt/fds_tinav2.1$
参考资料:
http://www.111cn.net/sys/linux/46433.htm
find -type d -empty
http://blog.csdn.net/u010555688/article/details/51280783
参考:http://bbs.chinaunix.net/forum.PHP?mod=viewthread&tid=1851432&page=1