Advertisement
metalx1000

Find and Delete files and folders

Jun 21st, 2017
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.38 KB | None | 0 0
  1. #find and delete files
  2. find -name 59.txt -delete
  3.  
  4. #If you want to make sure you only delete files and not folder
  5. find -type f -name 59.txt -delete
  6.  
  7. #if match is a folder the above won't work
  8. #so pass the matches to a command to execute
  9. find -name folder2 -exec rm -rf {} +
  10.  
  11. #if you want to make sure you only delete folders and not files
  12. find -type d -name folder2 -exec rm -rf {} +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement