The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
Unhappy Remove directory with exceptions

Hi,
I want to remove a directory recursively except the inside directories calles .SYNC (designsync dirs) I am looking for something like:

\rm -rf < find . * | grep -v .SYNC

The find works ok but I do not know how to redirect it.

Please help.

Regards,
Ziv
  #2 (permalink)  
Old 11-30-2009
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 6,006

Code:
cd /path/to/directory
rm -rf  $(find . * | grep -v .SYNC)

This will work but it is REALLY dangerous. Be careful.
  #3 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Jun 2006
Posts: 468
What's the meaning to put a * in your find script?

your request can be combined into one command:


Code:
find . ! -name "*.SYNC" -type f -exec echo rm -rf {} \;

if you review the output, and it is fine, then run below command to delete files.


Code:
find . ! -name "*.SYNC" -type f -exec rm -rf {} \;

  #4 (permalink)  
Old 12-02-2009
Registered User
 

Join Date: Oct 2009
Posts: 8
Thanks

The second solution solve it.
Regards,
Ziv
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove directory with exceptions zivsegal UNIX for Advanced & Expert Users 1 11-30-2009 12:44 PM
Remove contents of directory, but not directory pdc Shell Programming and Scripting 9 04-09-2009 03:02 PM
Can't remove a directory dkranes SUN Solaris 2 07-28-2008 11:38 AM
smitty, remove user, remove directory as well.. yls177 UNIX for Dummies Questions & Answers 2 11-11-2002 02:43 AM
remove a nonempty directory babayeve UNIX for Dummies Questions & Answers 2 08-26-2002 12:34 PM



All times are GMT -4. The time now is 10:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0