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
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 02:59 AM
Sun's 'Project Copy Linux' not a Linux copy - Register iBot UNIX and Linux RSS News 0 07-29-2007 05:31 AM
How to copy ? nani_ynm UNIX for Dummies Questions & Answers 4 01-09-2007 05:14 AM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-25-2006 12:20 AM
Copy iso faron17 UNIX for Dummies Questions & Answers 1 06-22-2005 08:36 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 05-16-2008
finalight finalight is offline
Registered User
  
 

Join Date: May 2008
Posts: 51
copy after grep

i think i got the order wrongly...

cp|grep "get" * test

it says argument for cp is 0


i only just want to copy files with the grep input pattern (all are text files definitely) from one directory into another
  #2 (permalink)  
Old 05-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You can't pipe cp to grep, that doesn't make sense. A pipeline takes the output from one command and feeds it as input to the next. So the output from cp is what you grep -- that's not what you want.

Where is the destination directory; is that test?

You want to copy all files which match the input pattern?

Code:
cp `grep -l get *` test
or

Code:
grep -l get * | xargs -i cp {} test
Sponsored Links
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:31 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