The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
searching for a string in a file ROOZ UNIX for Dummies Questions & Answers 2 03-07-2008 09:54 AM
Searching for files with certain string pattern intrigue UNIX for Dummies Questions & Answers 1 02-28-2008 01:28 PM
Perl: searching for a string in a file... pondlife Shell Programming and Scripting 4 09-17-2007 04:35 AM
Complicated string searching in a file nir_s Shell Programming and Scripting 5 09-21-2005 04:51 AM
searching for a string though file system peter.herlihy UNIX for Dummies Questions & Answers 3 12-06-2001 12:19 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-19-2007
Registered User
 

Join Date: Sep 2007
Posts: 1
Extracting a string from one file and searching the same string in other files

Hi,

Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get the lines containing that string.

please help me how to do this using awk or sed in unix.

Thanks,
Mohan.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-19-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
Wink Try This one

Let say you have file1 without delimeter and you want first 10 char as pattern to search in another files.

#!/bin/sh
cut -c1-10 file1 >pattern.txt
for pattern in `cat pattern.txt`
do
find $pattern file_name1 file_name2
done
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:05 PM.


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