Remove all but exclude particular file or directory

By neokrates, written on July 22, 2010

bash   snippet

Rate it
  • 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
Ad
Poll
  • What tools do you use for site design?

    • Something else (75%, 6 Votes)
    • Code directly to my site, no design tool (25%, 2 Votes)
    • Photoshop (0%, 0 Votes)
    • Artisteer (0%, 0 Votes)
    • Gimp (0%, 0 Votes)
    • Dream Weather (0%, 0 Votes)
    • Free online tools and generators (0%, 0 Votes)
    • Tools from my provider (0%, 0 Votes)
    • CoffeeCup tools (0%, 0 Votes)

    Total Voters: 8

    Vote

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext
Most popular search terms:

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"`
 
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
    nope :(
SOCIAL
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BlinkList
  • Blogosphere News
  • E-mail this story to a friend!
  • Furl
  • LinkArena
  • Live
  • MisterWong
  • Print this article!
  • StumbleUpon
  • Technorati
  • Webnews.de
  • YahooMyWeb

Leave a Reply