Skip to content

Instantly share code, notes, and snippets.

@JMatthewman
Last active February 26, 2018 08:16
Show Gist options
  • Save JMatthewman/8889493 to your computer and use it in GitHub Desktop.
Save JMatthewman/8889493 to your computer and use it in GitHub Desktop.
an alias to execut ls -lah with colour, and create octal permissions output
function ll() {
if [ "$*" == "" ]
then
input=./
else
input=$*
fi
ls "$input" -lah --color | awk '{
k = 0
s = 0
for( i = 0; i <= 8; i++ )
{
k += ( ( substr( $1, i+2, 1 ) ~ /[rwxst]/ ) * 2 ^( 8 - i ) )
}
j = 4
for( i = 4; i <= 10; i += 3 )
{
s += ( ( substr( $1, i, 1 ) ~ /[stST]/ ) * j )
j/=2
}
if ( k )
{
printf( "%0o%0o ", s, k )
}
print
}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment