0

How do I write a script that will list all files in a user-defined directory, as well as all sub-directories and order them by size? As well as give the user the option to delete any file that is a size of 0.

The script I have so far lists all files in current directory as well as sub-directories

for file in $( find . -type f ${dir} );
    do
    echo "$(basename "$file")"
done
icestorm0806
  • 691
  • 1
  • 9
  • 20
  • See [BashPitfalls #1](http://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29), and [DontReadLinesWithFor](https://mywiki.wooledge.org/DontReadLinesWithFor). – Charles Duffy Jul 08 '18 at 03:29
  • 1
    ...that said, you're asking a **lot** of different things here -- perhaps you should split it into separate questions. Some of them (like how to let the user define arguments to your script, and how to sort find results, and how to prompt for options) are already answered elsewhere on the site. – Charles Duffy Jul 08 '18 at 03:29

0 Answers0