Skip to content

Instantly share code, notes, and snippets.

@siwells
Created February 2, 2012 15:09
Show Gist options
  • Select an option

  • Save siwells/1723895 to your computer and use it in GitHub Desktop.

Select an option

Save siwells/1723895 to your computer and use it in GitHub Desktop.
Pipeline to inspect octal permissions of a file in a cross-platform (GNU & BSD Userland) fashion
ls -l $file | awk '{ print $1 }' | colrm 1 1 | sed -e 's/@$//' | sed -e 's/--x/1/g' -e 's/-w-/2/g' -e 's/-wx/3/g' -e 's/r--/4/g' -e 's/r-x/5/g' -e 's/rw-/6/g' -e 's/rwx/7/g' -e 's/---/0/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment