Trying to delete all directories within a folder under a set size
So I have a folder with files and folders in it
I want to delete just the folders and just the ones less then 100mb And also don't want to delete the main /home/steve/New folder Here's what I have so far: Code:
find /home/steve/New/ -size -100M -type d -exec rm -rf {} \; |
You can't do it that way. The reported size of a directory is just the size of the directory file itself (it holds the map of filenames to inode numbers) and does not include the sizes of the files under that directory. The only way to do what you want is to use the du command to see the total space used under each directory and parse the output according to your criteria. Note that parsing the output from du can be challenging if there are any directory names with "odd" characters, like newlines, backspaces, anything special to the shell, etc.
|
That's a little over my head.. Can I get a little help please?
|
Quick, untested loop that includes confirmation:
Code:
du -k /home/steve/New | while read Size Dname; do |
All times are GMT -5. The time now is 06:51 PM. |