Finding the Largest File in a Given Directory

I'm passionate about coding and enjoy working with embedded systems, app development, and compiler design.
This script accepts several arguments from the user and operates on each of them through a for loop.
The $* denotes all the arguments that are sent to the script. The loop iterates through each argument sequentially and assigns it to i.
Within the loop, the [ -d $i ] condition verifies whether the argument i is a directory.
If it is a directory, the program outputs a message saying it is looking for the biggest file. It then executes ls -l $1 to display files in long format within the first argument, which is the first directory provided by the user. The output is piped through grep "^-", which returns only regular files and not directories. The tr -s ' ' command compresses several spaces into one space for the sake of uniform formatting. The cut -d' ' -f5,8 command pulls out the file size and file name from the output. If the argument is not a directory, the program outputs that it is not a directory.
The loop runs until all arguments are verified.
#!/bin/bash
for i in $*
do
if [ -d $i ];
then
echo "large file size is"
echo `ls -l $1 | grep "^-" | tr -s ' ' |cut -d' ' -f5,8`
else
echo "not directory"
fi
done






