quick Linux question...

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
How can I repeat a command through all subdirectories of the current working directory? Like if I want to remove all .txt files from the directory I would do 'rm *.txt', but how could I repeat this for all subdirectories?
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
Originally posted by: Platypus
Use the recursive -R flag.

Unfortunately not.

'rm -R *txt' does not work, it's the first thing I tried. I believe that flag is for removing _all_ content from all subdirectories.
 

iroast

Golden Member
May 5, 2005
1,364
3
81
Use find with the -exec option


Edit
----------

find /targetdir -name "*.txt* -exec rm '{}'