Skip to content
Snippets Groups Projects
Commit 0610591a authored by leo.muff's avatar leo.muff
Browse files

ex2 ok

parent 8ed78a8f
No related branches found
No related tags found
No related merge requests found
......@@ -5,14 +5,30 @@ if [ $# -ne 1 ];then
exit 1
fi
FILES=$(ls -R $1)
FILES=$(find $1 -type f )
if [ $? -eq 1 ]; then
echo "folder not existing"
if [ $? -ne 0 ]; then
echo "folder does not exist"
exit 1
fi
if [ "$FILES" = " " ]; then
if [ "$FILES" = "$1:" ]; then
echo "folder empty"
exit 1
fi
MAX_SIZE=0
MAX_FILE=""
for f in $FILES; do
SIZE=$(stat -c %s $f)
if [ $SIZE -gt $MAX_SIZE ]; then
MAX_SIZE=$SIZE
MAX_FILE=$f
fi
done
if [ "$MAX_FILE" = "" ]; then
echo "all files are empty"
fi
echo "$MAX_FILE : $MAX_SIZE bytes"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment