Note though that parsing ls
is not generally recommended.
For an in-shell way, you can loop through the directory (or list of files) like this:
for file in * ; do
fsize=$( stat -c %s $file )
(( fsize > size )) && size=$fsize largest=$file
echo "The largest file is: $largest [$size]"
You can of course also add tests to ensure you exclude directories or whatever.