#!/bin/bash
dir=$1
if [[ -d "$dir" ]]; then find "$dir" -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
elif [[ "$#" -gt "1" ]]; then echo "More than one arguments, see -h for help"
fi
if [[ -f "$dir" ]]; then echo "It's not a directory!"
fi
if [[ -z "$dir" ]]; then echo "Enter directory name or -h , --help for help menu"
fi
if [[ "$dir" = '-h' ]]; then echo "help me"
elif [[ $dir == "--help" ]]; then echo "help me"
fi
More than 1 argument reports error, returns proper error code and show help message
#!/bin/bash
dir=$1
dir2=$2
if [[ -d "$dir" ]]; then find $dir -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
fi
if [[ -f "$dir" ]]; then echo "It's not a directory!"
fi
if [[ -z "$dir" ]]; then echo "Enter directory name"
fi
if [[ "$dir" = '-h' ]]; then echo "help me"
fi
if [[ "$dir" = '--help' ]]; then echo "help me"
fi
#!/bin/bash
dir=$1
dir2=$2
if [[ -d "$dir" ]]; then find $dir -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
else echo "Не директория!"
fi
if [[ "$dir" = '-h' ]]; then echo "help me"
fi
if [[ "$dir" = '--help' ]]; then echo "help me"
fi
if [[ "$dir" = '' ]]; then echo "No args"
fi
#!/bin/bash
dir=$1
dir2=$dir
if [[ "$dir" = "$1" ]]; then find $dir2 -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'
fi
if [[ "$dir" = '-h' ]]; then echo "help me"
fi
if [[ "$dir" = '' ]]; then echo "No args"
fi