find /tmp -printf '%s %p\n' |sort -n -r | head
This command is working fine but what are the %s %p
options used here? Are there any other options that can be used?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWhat are the %s %p options used here?
From the man page:
%s File's size in bytes.
%p File's name.
Scroll down on that page beyond all the regular letters for printf and read the parts which come prefixed with a %.
%n Number of hard links to file.
%p File's name.
%P File's name with the name of the starting-point under which it was found removed.
%s File's size in bytes.
%t File's last modification time in the format returned by the C `ctime' function.
Are there any other options that can be used?
There are. See the link to the manpage.
-printf "%TY-%Tm-%TdT%TT %p\n"
(including the double quotes) prefixes the file name with the modification time in ISO 8601 format. (On some systems, the seconds part is in nanosecond resolution which may ruin the display - a post filter, likeperl -nle 's/(\d\dT[^\.]+\.\d\d\d)\d+/$1/g; print $_'
, may be required).