I am supposed to make a script that prints all sizes and file-names in the current directory, ordered by size, using the “set” command.
#!/bin/bash
touch /tmp/unsorted
IFS='@'
export IFS
ls -l | tr -s " " "@" | sed '1d' > /tmp/tempLS
while read line
do
##set probably goes here##
echo $5 $9 >> /tmp/unsorted
done < /tmp/tempLS
sort -n /tmp/unsorted
rm -rf /tmp/unsorted
By logic, this is the script that should work, but it produces only blank lines.
After discussion with my classmates, we think that the “set” command must go first in the while loop. The problem is that we cant understand what the “set” command does, and how to use it. Please help. Thank you.
or simply