Georg Heiler
Georg Heiler

Reputation: 17724

zsh delete subdirectory with wildcard in path

For a directory structure of:

└── bar
    ├── first
    │   └── tmp
    └── second
        └── tmp

I want to delete all tmp directories. However,

rm -rf 'bar/*/tmp/'                                

does not delete the directory

ls bar/*/                                          

still retrurns both tmp directories:

bar/first/:
tmp

bar/second/:
tmp

Upvotes: 0

Views: 881

Answers (1)

Taylor Cochran
Taylor Cochran

Reputation: 455

your problem here is the single quotes

rm -rf 'bar/*/tmp/'          

if you remove them you'll be fine.

rm -rf bar/*/tmp

The reason for this is that single quotes in (most, if not all) shell languages indicates that the contained string of characters is to be treated entirely as a string, which ignores the globbing you are trying to do.

Upvotes: 1

Related Questions