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?


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.

  • @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 Nov 17 '17 at 9:53
  • 1
    @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. – don_crissti Nov 17 '17 at 12:52
  • 1
    @don_crissti Or they are on a server that has no manpages installed which is rather frequent. – runlevel0 Feb 15 '18 at 12:10
  • My manual page tend to be from FreeBSD though. Unless I happen to have a Linux VM within reach. And I have the impression that most questions are GNU/Linux based. – Hennes Feb 16 '18 at 16:16
  • 1
    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 Oct 26 '18 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.