Score:0

Finding largest file in a directory but only files not directories

cx flag

With this code I can find largest files in /usr directory which includes directories as well

du -a /usr | sort -n | tail -n 2

But I want only files not directories what can I do?

Score:0
cn flag

A find command can do this as:

find <folder> -type f -printf '%s %p\n'| sort -nr

Unless the du command, this will print the byte size of the file, not the space it actually takes up on disk. That, however, fits the goal expressed in your question of "finding largest file", so it may be the better tool for your job.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.