The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files but exclude the files in subdirectories shyjuezy UNIX for Dummies Questions & Answers 8 10-15-2008 01:42 PM
Coping files from server to local jhofilena Shell Programming and Scripting 3 09-19-2007 01:50 PM
du (exclude files) the_learner UNIX for Advanced & Expert Users 1 07-17-2007 02:06 PM
coping all files from a directory pavan_test UNIX for Dummies Questions & Answers 1 07-23-2006 04:35 AM
How to exclude files from printed results umen UNIX for Dummies Questions & Answers 2 09-18-2005 06:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2009
soliberus soliberus is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 87
coping files, need to exclude certain files

I have two directories that contain data files. I would like to create a script that would copy all data files (*.dbf) from these directories to another location, except for 4 specific files.

How do I exclude those files from my cp command?
  #2 (permalink)  
Old 05-26-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Doing a google once...... given me this...

Code:
find ./ ! -name '*.svn' | xargs -i cp {} dest_dir
will copy all files (excluding *.snv files).
  #3 (permalink)  
Old 05-26-2009
soliberus soliberus is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 87
The problem is that the files I want to exclude are also *.dbf files
  #4 (permalink)  
Old 05-26-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Code:
find . ! -name "a.dat" ! -name "rem.txt" -name "*.dat" |xargs  -i  cp {} DEST

When i executed the above command , all files except a.dat file copied to the DEST folder. Although (a.dat fall under *.dat , find still excludes tht file).

In your case exclude all the 4 files , by putting their filenames in the commnad above and try.
  #5 (permalink)  
Old 05-26-2009
soliberus soliberus is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 87
Thank you panyam, that worked perfectly
Closed Thread

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 On




All times are GMT -4. The time now is 02:51 AM.


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