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
Search for a string and copy the entire line forumthreads UNIX for Dummies Questions & Answers 3 06-29-2009 07:29 AM
Copy / string. Paulw0t Shell Programming and Scripting 6 03-10-2007 11:26 PM
Search a string from list of input files sivakumarvenkat UNIX for Dummies Questions & Answers 2 03-08-2006 06:08 PM
copy and rename list of files kinmak UNIX for Dummies Questions & Answers 7 02-27-2005 09:23 PM
find and copy string in a file vascobrito UNIX for Advanced & Expert Users 10 03-03-2004 02:14 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2007
redlotus72 redlotus72 is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 69
How to List and copy the files containing a string


I have more than 8000 files in a dir, I need to copy to other dir which containing the "sample"

I tried
grep -il "1189609240791-1268115603299237276@216.109.111.119 ' | cp /tmp/inv

Nothing is happening for long time for 100 file dir too,

Any one can help me?
  #2 (permalink)  
Old 09-28-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
For filenames with no embedded spaces(or other pathological characters):

Code:
mv $(grep -l '1189609240791-1268115603299237276@216.109.111.119')  /tmp/inv
Otherwise write a loop.

Aah, and if you get "too many arguments",
use zsh/zargs

Last edited by radoulov; 09-28-2007 at 10:26 AM..
  #3 (permalink)  
Old 09-28-2007
redlotus72 redlotus72 is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 69
Quote:
Originally Posted by radoulov View Post
For filenames with no embedded spaces(or other pathological characters):

Code:
mv $(grep -l "1189609240791-1268115603299237276@216.109.111.119 ')  /tmp/inv
Otherwise write a loop.

Aah, and if you get "too many arguments",
use zsh/zargs
Its not working...

ctlrws001[/tmp/inv1]$ cp $(grep -l "1190151616066-4284832706333417688@216.109.111.119') /tmp/inv/test
>
ctlrws001[/tmp/inv1]$ grep -l "1190151616066-4284832706333417688@216.109.111.119
>
  #4 (permalink)  
Old 09-28-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
The quotes are mismatched.
  #5 (permalink)  
Old 09-28-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
Quote:
Originally Posted by reborg View Post
The quotes are mismatched.
Yep, corrected
  #6 (permalink)  
Old 09-28-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
Quote:
Originally Posted by redlotus72 View Post
Its not working...

ctlrws001[/tmp/inv1]$ cp $(grep -l "1190151616066-4284832706333417688@216.109.111.119') /tmp/inv/test
>
ctlrws001[/tmp/inv1]$ grep -l "1190151616066-4284832706333417688@216.109.111.119
>
Check the corrected version
  #7 (permalink)  
Old 09-28-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
Just curious, I tried this:
Code:
zsh 4.3.4% for i ({1..400000}) touch "$i".txt
Ctrl+C after a while.
Code:
zsh 4.3.4% rm *txt
zsh: argument list too long: rm
zsh 4.3.4% autoload zargs
zsh 4.3.4% zargs *txt rm --
zargs:168: subscript too big: 397905
zsh 4.3.4% while :;do rm *.txt([1,20000]);done
zsh: argument list too long: rm
The solution was:
Code:
while :;do rm *.txt([1,10000]);done
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 06:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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