Reputation: 461
Is it possible to write a bash command that would write to a file a (key, value) structure that would represent every file within given directory and its corresponding file permissions as octal number (i.e. 664)? I know this command returns an octal value:
stat -c '%a' /path/to/file/
but I don't know how to combine it with walking through a directory and writing it out to a file. What might be useful is also this command that creates my_md5.txt file with key, value like structure of hash codes...
find /path/to/file/ -type f -exec md5sum {} \; > /tmp/my_md5.txt
but I don't know how to combine the two bits of code to do what I want. Any ideas?
Upvotes: 0
Views: 368
Reputation: 4164
You mean something like that?
find -type f -exec stat -c "%n: %a" {} \; | cut -b 3- > output.txt
explanation
Upvotes: 2