Skip to content

Instantly share code, notes, and snippets.

@istairbn
Last active May 16, 2017 10:26
Show Gist options
  • Save istairbn/5fb0b0c1a6e60e0a543a6fedc5b5c8b8 to your computer and use it in GitHub Desktop.
Save istairbn/5fb0b0c1a6e60e0a543a6fedc5b5c8b8 to your computer and use it in GitHub Desktop.
Outputs a JSON file with the relative path as the key and the octal permissions as the value
#!/bin/bash
#If path given as argument, that is used as the starting point. Else it starts from .
if [ -z "$1" ]; then
1="."
fi
echo "{"
SEP=""
find "${1}" | while read DIR
do
stat "${DIR}" -c "$SEP\"%n\":\"%a\""
SEP=","
done
echo "}"
@istairbn
Copy link
Author

Addition to deal with spaces in file names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment