#!/usr/bin/env bash if [[ $1 == "-v" ]]; then export verbose=1 shift fi file="$1" echo $(realpath "$file") if [[ -n "$verbose" ]]; then perm=$(stat --printf "%a" "$file") declare -A permMap=( [0]="no perms" [1]="execute" [2]="write" [3]="write, execute" [4]="read" [5]="read, execute" [6]="read, write" [7]="read, write, execute" ) owner="${permMap[${perm:0:1}]}" group="${permMap[${perm:1:1}]}" other="other:\t\t\t${permMap[${perm:2:1}]}" else owner="" group="" other="" fi stat --printf "octal: %a\nhuman: %A\nowner: %U (%u)\t$owner\ngroup: %G (%g)\t$group\n$other" "$file"