Search for string in a file then compare it with excel files entry | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Search for string in a file then compare it with excel files entry

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-16-2013
Anamika08 Anamika08 is offline
Registered User
 
Join Date: Oct 2013
Last Activity: 21 October 2013, 8:39 AM EDT
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Search for string in a file then compare it with excel files entry

All,
i have a file text.log:
cover6
cover3
cover2
cover4

other file is abc.log as :
0
0
1
0

Then I have a excel file result.xls that contains:

Name Path Pass
cover2
cover3
cover6
cover4

Now I want to write a perl script that will check if 1st column and 2nd row of results.xls is equal to first string of text.log then, write 1st string of abc.log in 3rd column 1st row of result.xls i.e under Pass field.

example : Row 2 of result.xls contain cover2 but in text.log cover2 is in 3rd line. So, row2 3rd column of result.xls will contain string in 3rd line of abc.log i.e 1.

Similarly for all rows.

Regards,
Anamika

---------- Post updated at 04:53 AM ---------- Previous update was at 04:28 AM ----------

Quote:
Originally Posted by Anamika08 View Post
All,
i have a file text.log:
cover6
cover3
cover2
cover4

other file is abc.log as :
0
0
1
0

Then I have a excel file result.xls that contains:

Name Path Pass
cover2
cover3
cover6
cover4

Now I want to write a perl script that will check if 1st column and 2nd row of results.xls is equal to first string of text.log then, write 1st string of abc.log in 3rd column 1st row of result.xls i.e under Pass field.

example : Row 2 of result.xls contain cover2 but in text.log cover2 is in 3rd line. So, row2 3rd column of result.xls will contain string in 3rd line of abc.log i.e 1.

Similarly for all rows.

Regards,
Anamika

Last edited by Anamika08; 10-16-2013 at 05:53 AM.. Reason: modified details
Sponsored Links
    #2  
Old 10-23-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 29 August 2014, 5:00 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,409
Thanks: 8
Thanked 539 Times in 517 Posts
This is the wrong forum, for sure!

I'd just run the xls through xls2txt in shell, get my value, grep for the line number, use sed or a shell loop to grab the right line. Of course, you can do it in PERL, or any other language with xls libraries, but if you do not learn PERL how can you maintain it?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search string within a file and list common words from the line having the search string royzlife Shell Programming and Scripting 12 10-21-2013 03:09 PM
Compare columns of multiple files and print those unique string from File1 in an output file. owwow14 Shell Programming and Scripting 5 10-15-2013 10:51 PM
Compare 2 files print the lines of file 2 that contain a string from file 1 KevinRidley UNIX for Dummies Questions & Answers 6 07-09-2011 05:44 PM
To compare first two columns in an excel file arunmanas UNIX for Dummies Questions & Answers 2 06-28-2011 02:10 AM
count the number of files which have a search string, but counting the file only once sudheshnaiyer UNIX for Dummies Questions & Answers 1 08-11-2007 01:50 PM



All times are GMT -4. The time now is 03:03 AM.