LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2011, 04:27 AM   #1
anaskoara
LQ Newbie
 
Registered: Jan 2011
Posts: 15

Rep: Reputation: 0
Question Exclude dir from find command


Hi i have this find command to find modified files and copy them

Code:
find $SRC_DIR -type f -ctime -1|xargs -i cp --parents {} $BACKUP_DIR/$DAY/
and it works good but it want to exclude files that exist in some folders like $SRC_DIR/cash and $SRC_DIR/woks/tmp

what is the best solution.

Regards
 
Old 02-05-2011, 04:32 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Have a look at -path option with -prune
 
Old 02-05-2011, 05:15 AM   #3
anaskoara
LQ Newbie
 
Registered: Jan 2011
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by grail View Post
Have a look at -path option with -prune
I've read the manual but I did not understand it can you explain it to me?
 
Old 02-05-2011, 06:07 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Use -path to name the directories you wish to exclude and then -prune to do the actual exclusion.
So your might look like:
Code:
find $SRC_DIR -type f -ctime -1 -path $SRC_DIR/cash -prune -o -print |xargs -i cp --parents {} $BACKUP_DIR/$DAY/
You may need to play around and experiment to get exactly what you need.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] 'find' command regex to exclude hidden files? arashi256 Linux - Newbie 3 06-28-2010 08:53 AM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 12:36 AM
How to exclude certain path from find command. UltraSoul Linux - Software 8 05-16-2009 06:26 PM
exclude a dir via find in bash? agrestic Programming 3 01-30-2009 03:32 PM
command to find size of a dir Longinus Linux - Newbie 3 08-01-2004 08:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration