Remove all but exclude particular file or directory

By neokrates, written on July 22, 2010

bash   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 45 views
Rate it
Ad
Poll
  • Your favorite way to manage packages is?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

It is possible, for example by combining find, rm and grep.

Example
Recursively clean current directory but not file or dir named “maven” and not “.m2”.

rm -r `find . |grep -v "maven"|grep -v ".m2"`
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: 0 (from 0 votes)
0 votes 'YES'  0 votes 'NO'
TAGS
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply