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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying files from one directory to Other satishkeshetty UNIX for Dummies Questions & Answers 3 04-14-2008 08:08 AM
shell script to selectively tar directory based on date fara_aris Shell Programming and Scripting 2 03-16-2008 07:35 PM
Loop through files in dir, omit file with latest date stringzz Shell Programming and Scripting 2 12-04-2007 02:04 PM
Copying file names returned from a grep command into another directory Kartheg UNIX for Dummies Questions & Answers 4 11-17-2005 12:34 PM
can we list other than c files in a directory with only 'ls' command? venkat UNIX for Dummies Questions & Answers 3 03-12-2004 09:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-10-2005
d_sai_kumar d_sai_kumar is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 3
Using cp -r command to selectively omit *.dat files while copying a directory.

Hi all,
I want to copy a directory named Ec1 to another directory named Ec2, newly created. But Ec1 has a bunch of *.dat files and many many other kinds of files. Whle creating Ec2, I selectively want to omit the *.dat files since they are huge files of the order of 100 MBs and there are hundreds of such files which would consume a lot of time.

How can I use the 'cp -r' command to selectively omit the *.dat files in Ec1 and obtain the Ec2 directory without any *.dat files while copying the directory Ec1.

Any suggestions are appreciated.

Thanks,
Sai.
  #2 (permalink)  
Old 11-10-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
It's easier not to use, cp -r

Code:
cd /the/path/to/EC1
find . depth ! -name "*.dat" | cpio -pdmv /the/path/to/EC2

Last edited by reborg; 11-10-2005 at 01:30 PM.. Reason: more info
  #3 (permalink)  
Old 11-10-2005
d_sai_kumar d_sai_kumar is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 3
Thanks.

You are a genius reborg!

This is what I did, and it worked.
cd Ec1/
find . -depth ! -name "*.dat" | cpio -pdmv ../Ec2

In the first part, I am guessing that you are finding all the files without a *.dat and then you are piping the output into Ec2. Just curious, what do the cpio and -pdmv do?

Thanks a lot,
Sai.
  #4 (permalink)  
Old 11-11-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
-p pass trough (copy in and out)
-d make dirs
-m preserve modification time
-v verbose

from the man page:
Code:
       ....cpio copies files
       into or out of a cpio or tar archive, which is a  file  that  contains
       other  files  plus  information  about  them, such as their file name,
       owner, timestamps, and access permissions.  The archive can be another
       file  on the disk, a magnetic tape, or a pipe.
  #5 (permalink)  
Old 07-18-2008
madankumar madankumar is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore
Posts: 8
Thumbs up Hi

Hi It was very excellent .... made my job easy.

I have another question ....
Dir1 I have some files *.dat
Dir2 I have script to run .... I would like to pass the all *.dat files to the script in dir2 without path ( only the file names) ... can anyone help me in this

Thanks in advance

Madan
  #6 (permalink)  
Old 07-18-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,063
cd /Dir1
cp -p *.dat /Dir2/
Closed Thread

Bookmarks

Tags
cpio

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 11:11 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