Hi ,
I need a script which basically deltes all files in folder a which are alreasy present in folder b
say folder a has files
abc.txt
pqr .txt
and b has
abc.txt
pqr.txt
rmr.txt
then file abc.txt and pqr.txt from a should be deleted
Hi ,
I need a script which basically deltes all files in folder a which are alreasy present in folder b
say folder a has files
abc.txt
pqr .txt
and b has
abc.txt
pqr.txt
rmr.txt
then file abc.txt and pqr.txt from a should be deleted
check if this heps you get started:
for file in /path/tp/b/*
do
echo check if $file exists in directory a
done
what have you tried so far?
for file in `ls folderb`
do
find foldera -type f -name "$file" -exec rm -f {} \;
done
you can also try diff command to get listing.
-bash-3.2$ diff fol1 fol2 | grep fol1
Only in fol1: b.txt
Only in fol1: c.txt
-bash-3.2$
for i in $(ls -1 /home/pritish/a);do
for j in $(ls -1 /home/pritish/b);do
if [ $i == $j ]; then
$(rm -i /home/pritish/a/$i)
fi
done
done
for i in `ls dir1`;do
if [ -f dir2/$i ]; then
rm dir1/$i
fi
done