分类:
2006-04-12 01:28:41
#!/bin/bash ls aa > a.txt ls bb > b.txt # print the files only in aa , and save the file name to arrary only_in_aa only_in_aa=(`diff -P aa bb | awk '{print $NF}'`) str=`echo ${only_in_aa[@]} | tr ' ' '|'` # print the files in aa same with in bb cat a.txt | grep -Ev "$str" > same_with_bb # if you want to delete the files in aa same with bb for i in `cat a.txt | grep -Ev "$str"` do rm -f ./aa/$i done |