Reputation: 350
I'm looking for a bash script, than can list all the folders, that have
a) subfolders
or
b) more than 1 file bigger than size X
Sadly my bash-fu is not that good to accomplish something like this, I wouldn't even know what to pipe together for something like this.
Regarding a) I have no idea where to start (fiddle with ls -R
?)
Regarding b) I already can list all files bigger than size X with:
du -sm * | awk '$1 > 500'
But from there on, I'm stuck.
Thanks a lot for your help in advance guys.
Upvotes: 0
Views: 159
Reputation: 181
a) subfolders
find . -type d | awk -F/ 'NF>2{print $2}' | sort -u
b) file size greater than 500mb
find . -type f -printf "%p %k\n" | awk '$NF>500000'
Upvotes: 1
Reputation: 67507
For a) find
with awk
and sort
$ find . -type d | awk -F/ -v OFS=/ '{NF--} NF' | sort -u
find all directories, remove the last level, remaining ones are parents only with multiplicity, then filter. Assumes no newlines in filenames.
For b) similarly
$ find . -size +1M | awk -F/ -v OFS=/ '{NF--} NF' | sort -u
this is for greater than 1Mb, if you want 500b, change to +500c
Upvotes: 1