I wanted to find and delete all files of Season 1 of a particular TV show.
[[email protected]] ~/ # find . -iname '*S01*' -type d ./Poirot S01E09 - The King of Clubs (1989) ./Poirot S01E02 - Murder In The Mews (1989) ./Poirot S01E04 - Four And Twenty Blackbirds (1989) ./Poirot S01E05 - The Third Floor Flat (1989) ./Poirot S01E03 - The Adventure Of Johnnie Waverly (1989) ./Poirot S01E10 - The Dream (1989) ./Poirot S01E01 - The Adventure of the Clapham Cook (1989) ./Poirot S01E08 - The Incredible Theft (1989)
Now trying to delete them with the find -delete option:
[[email protected]] ~/ # find . -iname '*S01*' -type d -delete find: cannot delete `./Poirot S01E05 - The Third Floor Flat (1989)': Directory not empty find: cannot delete `./Poirot S01E03 - The Adventure Of Johnnie Waverly (1989)': Directory not empty find: cannot delete `./Poirot S01E10 - The Dream (1989)': Directory not empty find: cannot delete `./Poirot S01E01 - The Adventure of the Clapham Cook (1989)': Directory not empty find: cannot delete `./Poirot S01E08 - The Incredible Theft (1989)': Directory not empty
What I wanted was this:
[[email protected]] ~/ #find . -iname ‘*S01*’ -type d -exec rm -r {} +
[[email protected]] ~/ #find . -iname ‘*S01*’ -type d
There, the directories have been deleted.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.