Quote:
Originally Posted by Paraply
"rm -r ./*_files" --> works, but only in the first directory. It looks to me as if "./" is disabling the recursive functionality.
What am I doing wrong?
|
the ability of the humans mind to associate and to "understand" what others mean is called empathy. it isn't implemented in any computer yet, as far as i know. you have to exactly tell the computer what it should do. they are not good at guessing
.
the "-r" option tell rm to remove a directory by recursivly travelling it down and removing each and every file/dir in it up to the top directory.
the command "rm -r ./*_files" does the following:
1. check the directory "./" for entries (inodes) matching the pattern "*_files".
2. if you find one, remove it (recursivly if necessary, i.e. if it's a directory)
it does not mean "travel all the subdirs in "./" recursivly till you find an entry matching the pattern "*_files" and then remove it recursively. your command implies to recursions yet you have told the bash only of one. in other words: if you have a directory ./somedir/dir_files/ the above command will not find the dir "dir_files" because "rm" only searches the directory "./" (note: the "-r" option doesn't mean "search recursivly" but "remove recursivly")
to solve your problem you should use find and xargs:
Code:
find ./ -name '*_files' | xargs rm -r
but try this command first without xargs and check the output to make sure it found all files correctly.
cheers :::
p.s. these live topics kill me. there was one answer when wrote my reply just to find out that meanwhile other recommended the same and a lot easier.