I am trying to create a script to list files by size. I was able to show a long listing before adding parameters (first comment) but nothing seems to work after trying to add them. If the first or only parameter is -r the output should be descending order by size, if the parameter is anything else like "*.c" it should list all C programs before passing the output to the grep and sort.
The script says if found "-r" when it isn't there and vice versa and entering a star name parameter expands to the first occurrence of the specified item.
All ideas appreciated. TIA
rev=""
if [ $# -gt 0 ]
then
if [ $1 -eq "-r" ]
then
rev="-r"
echo found -r
shift
fi
fi
#ls -l |grep -v "total " |sort +4n -5 +8
#ls -l $1 |grep -v "total " |sort $rev +4n -5 +8 |more -e
echo ls -l $1 grep -v "total " sort $rev +4n -5 +8 more -e