find if files in one directory recursively exists in another directory recursively in linux bash and print exists or not exists
lets say you have
pth1/dirA/file1
pth1/dirA/DirB/file2
andpth2/dirA/file1
pth2/dirA/DirB/file3
I want a report that
file1 exists
files2 dont exist in pth2
files3 dont exist in pth1
i have found that code that works for current level for both directories, but i cant make it work recursively taken from here
pth1="/mntA/newpics";
pth2="/mntB/oldpics";
for file in "${pth1}"/*; do
if [[ -f "${pth2}/${file##*/}" ]]; then
echo "$file exists";
fi
done
How I can do it to work recursively on both paths?
pth1/dirA/file1
, are you wanting to see if there is a file calledfile1
anywhere at all underneath yourpth2/dirA
? Or must it be at the same relative place? What about comparing file contents, or are you just interested in the names?