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?

  • 6
    Take a look at find's manpage.
    – Cyrus
    Commented Jul 11, 2015 at 6:41
  • possible duplicate of Where to find printf formatting reference?
    – phuclv
    Commented Oct 9, 2017 at 3:13
  • 3
    The documentation on the man page for find is very very convoluted with redirect upon redirect. For instance, it is not easy to synthesise that -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, like perl -nle 's/(\d\dT[^\.]+\.\d\d\d)\d+/$1/g; print $_', may be required). Commented Jan 18, 2022 at 18:46

1 Answer 1


What 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.

  • 1
    @don_crissti I'll never understand why people prefer random web documentation to the documentation installed on their systems (which has the added benefit of actually being relevant to their system).
    – Kusalananda
    Commented Nov 17, 2017 at 9:53
  • 2
    @Kusalananda - Well, I can think of one scenario in which people would include a link to a web page instead of a quote from the documentation installed on their system: they're not on a linux machine at the time of writing the post... However, the link should point (imo) to the official docs (hence my comment above, which, for some unknown reason, was deleted by the mods...). That aside, I fully agree with you: the OP should consult the manual page installed on their system. Commented Nov 17, 2017 at 12:52
  • 2
    @don_crissti Or they are on a server that has no manpages installed which is rather frequent.
    – runlevel0
    Commented Feb 15, 2018 at 12:10
  • 4
    @don_crissti I can think of several reasons. For starters, man pages are usually written with every feature explained, in whatever order makes sense to the programmer. That's not usually helpful at all to normal users. I've been scripting for 35 years, and these days I search stackexchange first, then worst-case (almost never) fall back to man page.
    – Jim
    Commented Oct 26, 2018 at 4:15
  • 8
    I should also add that, in addition to overwhelming and often inscrutable output of man pages for relatively inexperienced users, as a programmer/power user I'm usually looking for novel solutions that man pages don't cover. For example (just now), specific date format for 'find' command output. The man page doesn't tell you to put "%T" in front of each variable--at least not that I found even looking for that specifically. You could spend all day trying to figuring it out. (Or just give.) Whereas a search on Stack Exchange will yield that answer, clearly explained, in the first result.
    – Jim
    Commented Oct 26, 2018 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .