In a unix/linux environment I get a list of hundreds of files that need to be deleted. This list comes to me every week in the form of a text file and I need to do two things.
- Check to see how many bytes are involved.
- Delete the files.
Some of the files have spaces in their names. Two scripts are used. One for checking and one for deleting.
Following is the script for checking:
#!/bin/bash for token in `cat $1` do printf “du -sk \ “%s\” \n” $token >> $1.sh doneFollowing is the script for deleting:
#!/bin/bash for token in `cat $1` do printf “rm -rf \ “%s\” \n” $token >> $1.sh done