Sample Header Ad - 728x90

How can I move all directories below a certain size?

0 votes
5 answers
163 views
I want to move all directories in the current directory that are below a certain size Here, I've managed to do a selection:
for dir in *
do
    if [[ $(du -s "$dir" | awk '{print $1}') -le 50000 ]]
    then
      ls -l "$dir"
    fi
done
I now figured I should use dirname to get the directory, but somehow it complains no matter what I do;) Do we have a neat way to do this?;)
Asked by Jason Hunter (227 rep)
Oct 9, 2023, 12:13 PM
Last activity: Oct 10, 2023, 07:05 AM