Thursday, May 31, 2012

Show Linux or *nix permissions in octal

Like many others before me, I briefly Googled for "ls show octal permissions" (without quotes) and got next to nothing immediately useful: https://www.google.com/search?q=ls+show+octal+permissions

I would've written the solution to this thread since I got this idea from there, but unfortunately, it's closed: http://www.unix.com/unix-dummies-questions-answers/119538-ls-switch-view-octal-permissions.html

Solution: ditch ls and use stat instead---stat can format its output similar to date.
$ stat -c %a "${filename}"
644

No comments:

Post a Comment