Skip to content

stat

Get currently logged in console user's shortname

stat -f '%Su' /dev/console

Nicely display permissions in octal format with filename

stat -c '%A %a %n' *

View Owner, Group & Permissions.

stat -c '%n %U:%G-%a' *

STAT Function showing ALL info, stat options, and descriptions

statt(){ C=c;stat h|sed '/Th/,/NO/!d;/%/!d'|while read l;do p=${l/% */};[ $p == %Z ]&&C=fc&&echo ^FS:^;echo "`stat -$C $p \"$1\"` ^$p^${l#%* }";done|column -ts^; }

Nicely display permissions in octal format with filename

stat -f '%Sp %p %N' * | rev | sed -E 's/^([^[:space:]]+)[[:space:]]([[:digit:]]{4})[^[:space:]]*[[:space:]]([^[:space:]]+)/\1 \2 \3/' | rev

Get current logged in users shortname

stat -f%Su /dev/console

list files recursively by size

stat -c'%s %n' **/* | sort -n

Display the format of a directory or file

stat -f -L -c %T YOUR_FILE_OR_DIRECTORY

Status of a file/directory

stat /etc/my.cnf

Execute md5sum and sha in the same files in a single command.

stat -c %n * |tee >(xargs md5sum >estedir.md5) >(xargs sha512sum  >estedir.sha)

File size

stat format "%s" <file>

File size

stat -c "%s" <file>

Nicely display permissions in octal format with filename

stat -c '%A %a %n' *

View Owner, Group & Permissions.

stat -c '%n %U:%G-%a' *

STAT Function showing ALL info, stat options, and descriptions

statt(){ C=c;stat h|sed '/Th/,/NO/!d;/%/!d'|while read l;do p=${l/% */};[ $p == %Z ]&&C=fc&&echo ^FS:^;echo "`stat -$C $p \"$1\"` ^$p^${l#%* }";done|column -ts^; }

Nicely display permissions in octal format with filename

stat -f '%Sp %p %N' * | rev | sed -E 's/^([^[:space:]]+)[[:space:]]([[:digit:]]{4})[^[:space:]]*[[:space:]]([^[:space:]]+)/\1 \2 \3/' | rev

Get current logged in users shortname

stat -f%Su /dev/console

list files recursively by size

stat -c'%s %n' **/* | sort -n

Display the format of a directory or file

stat -f -L -c %T YOUR_FILE_OR_DIRECTORY

Last update: August 10, 2022
Created: August 10, 2022