Using script to do something for all files of a folder

#!/bin/bash
# here we try to separate files
#1. that are included in other files
# 2. that are not

folder=/opt/myfolder

echo > a.txt
find $folder | while read filepath
do
file=`basename "$filepath"`
usedin=`grep -r "$file" $folder`
if [ "$usedin" = "" ]
then
echo "$filepath" >> a.txt
else
echo "$filepath"
echo ======
echo $usedin
fi
done

No comments: