How to compare 2 folders' permission on Unix?

compare, directory, permissions, unix

Solution

One way to compare permissions on your two directories is to capture the output of `ls -al` to a file for each directory and `diff` those.

Say you have two directories called a and b.

cd a
ls -alrt > ../a.list
cd ../b
ls -alrt > ../b.list
cd ..
diff a.list b.list

If you find that this gives you too much noise due to file sizes and datestamps you can use awk to filter out some of the columns returned by ls e.g.:

ls -al | awk {'printf "%s %s %s %s %s %s\n", $1,$2,$3,$4,$5,$9 '}

Or if you are lucky you might be able to remove the timestamp using:

ls -lh --time-style=+

Either way, just capture the results to two files as described above and use `diff` or `sdiff` to compare the results.

Problem

Given 2 folder: /folder1 and /folder2 and each folder has some files and subfolders inside. I used following command to compare the file difference including sub folder : ``` diff -buf /folder1 /folder2 ``` which found no difference in term of folder and file structural . However, I found that there are some permission differences between these 2 folders' files. Is there simple way/command to compare the permission of each file under these 2 folders (including sub-folders) on Unix? thanks,

Original source

Related problems