The UNIX and Linux Forums  


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
Grep help flood Shell Programming and Scripting 3 06-06-2008 02:14 AM
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 08:10 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 05:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 03:59 AM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-25-2006 01:20 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 08-05-2006
venu_nbk venu_nbk is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 33
How to Cp using grep

I need copy some files into another folder.
But not all the files excluding a directory in the actual folder I need to copy all the remaining folders and files into another folder.

cp * temp | grep -v logs

is the command I am trying. But am not able to get it.
Could anyone help me out

Thanks
  #2 (permalink)  
Old 08-05-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
use find

See if it works for you

Code:
for file in `find . \( ! -name "logs" -only \) -type f `
do
cp $file /destination/directory
done

where, logs is the directory you want to skip
  #3 (permalink)  
Old 08-05-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2006
Posts: 360
Quote:
Originally Posted by ranj@chn
See if it works for you

Code:
for file in `find . \( ! -name "logs" -only \) -type f `
do
cp $file /destination/directory
done

where, logs is the directory you want to skip
try simply

Code:
find . \( ! -name "logs" \) -type f -exec cp {} /destination/directory \;

  #4 (permalink)  
Old 08-05-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
yes

That is also possible..Thanks Hitori..
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 01:38 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