You can use the find command as follows to find and delete file in bulk:
OR
find /path/to/delete -type f -iname "fileType" -delete
To delete all *.bak files in bulk from /netapp/ and its subdirectory, enter:
find /path/to/delete -type f -iname "fileType" -exec rm -f {} \;
# find /netapp/ -type f -iname "*.bak" -delete
OR
# find /netapp/ -type f -iname "*.bak" -exec rm -f {} \;
Shell Scripting Example
In this example, you've a file called delete.txt (with 5000 entries, each per line) and you need to delete all those files:/netapp/one.txtCreate a shell script as follows to read a text file using while loop one line at a time:
/netapp/dir2/one.txt
/netapp/dir1/dir500/one.txt
....
...
....
/netapp/fivek.txt
#!/bin/bash
_input="/path/to/delete.txt"
[ ! -f "$_input" ] && { echo "File ${_input} not found."; exit 1; }
while IFS= read -r line
do
[ -f "$line" ] && rm -f "$line"
done < "${_line}"
No comments:
Post a Comment