The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search for lines in a file shalua Shell Programming and Scripting 9 04-22-2008 08:28 PM
deleting a varying amount of lines from a list of files benair Shell Programming and Scripting 4 04-14-2006 10:48 AM
Search a string from list of input files sivakumarvenkat UNIX for Dummies Questions & Answers 2 03-08-2006 02:08 PM
List files that do not match the search pattern olapxpert UNIX for Dummies Questions & Answers 7 04-14-2005 12:49 PM
List files that do not match the search pattern olapxpert IP Networking 1 04-14-2005 11:37 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-2008
Registered User
 

Join Date: Mar 2007
Posts: 19
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Search a list of lines in file into files

I have a file (file1) which is like

host1
host2
host3
host4
the list goes on............


Now I want the above lines in files to be compared with files under
/opt/new/

File names are as below:
Dev
Prod
QA

And suppose host1 from file1 is found under Dev(file under /opt/new) than it should write under a seperate file New-list as host1-DEV

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-19-2008
agn agn is offline
Registered User
 

Join Date: Feb 2008
Posts: 76
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Code:
while read line; do echo ${line}-$(grep -l $line /opt/new/*); done < buf > new-buf

Last edited by agn; 05-19-2008 at 10:20 PM. Reason: screwed up code block
Reply With Quote
  #3 (permalink)  
Old 05-20-2008
Registered User
 

Join Date: Mar 2007
Posts: 19
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Thanks:

Thanks, It worked !
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101