How to find the largest file in a directory and its subdirectories?

前端 未结 15 1366
醉梦人生
醉梦人生 2020-11-28 18:29

We\'re just starting a UNIX class and are learning a variety of Bash commands. Our assignment involves performing various commands on a directory that has a number of folder

15条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 19:00

    On Solaris I use:

    find . -type f -ls|sort -nr -k7|awk 'NR==1{print $7,$11}' #formatted
    

    or

    find . -type f -ls | sort -nrk7 | head -1 #unformatted
    

    because anything else posted here didn't work. This will find the largest file in $PWD and subdirectories.

提交回复
热议问题