Skip to content

Instantly share code, notes, and snippets.

@wallentx
Created March 26, 2016 00:53
Show Gist options
  • Save wallentx/973da62b6d6b7fef751d to your computer and use it in GitHub Desktop.
Save wallentx/973da62b6d6b7fef751d to your computer and use it in GitHub Desktop.
A combination of ls and stat
#!/bin/bash
# This script will print a colorized list of files and folders from the current directory
# and show the user:group ownership, as well as the file permissions in a human-readable format
# TODO: add options to show/hide hidden files
LSOWN=$(ls -ACl --group-directories-first . | awk '{print $9}' | sed 1d)
CLIST=$(ls -AFCl --group-directories-first --color=always . | awk '{print $9}' | sed 1d)
statlist () {
for i in $LSOWN; do
stat -c '%a %U:%G' $i;
done
}
STAT=$(statlist)
paste <(echo "$STAT") <(echo "$CLIST") -d ' ' | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment