Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    That will also match oldCaches and badSnapshot etc. It will also break on the (unlikely) case of filenames with newlines and the (much likelier) case of filenames with spaces. It will also fail on cases where you have files whose name starts with a -. Commented Jun 14, 2014 at 16:06
  • should you have file names with spaces then a slight change in above will solve this issue as well ` find . -type ... | sed 's/^/"/;s/$/"/' | xargs -ifile rm file` Commented Jun 14, 2014 at 16:45
  • Yes, but that will break on, for example, files like foo bar" baz. If you want to make it really safe, you need find . -type f -print0 | xargs -0 rm or similar constructs. In any case, this does not help the main problem which is that you are not checking in the right places since grep Caches will match any file whose name or path contains Caches anywhere. Commented Jun 14, 2014 at 16:51
  • if to grep like this grep '\/Caches\/' and so on then your concern is also considered. Commented Jun 14, 2014 at 16:54