To list the larger file in a folder
ls -sh /pathFolder | sort -rh | head -n 1
The output of ls -sh
is a sized s
and human h
understandable view of the file size number.
You could use ls -shS /pathFolder | head -n 1
. The bigger S
from ls
already order the list from the larger files to the smaller ones but the first result its the sum of all files in that folder. So if you want just to list the bigger file, one file, you need to head -n 2
and check at the "second line result" or use the first example with ls sort head
.