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