LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-29-2010, 02:24 AM   #1
shilpa.godhe
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
How to compare two columns in a file.


Hi All,
I am trying to write a script which compares a log file with reference file. The log file has a table, the LHS of the table are constants strings and RHS of table values changes if there are any changes in configuration.

for example.

test.log

SYS_NAME=xyz
SNET_SPEED=3
MODEL_NAME=G2IP5C
SWITCH_TYPE=1
PCI_SLOTS=1.4C,2.EM,3.DC,4.EM,5.VO

test.Ref

SYS_NAME=string
SNET_SPEED=digit
MODEL_NAME=string
SWITCH_TYPE=digit
PCI_SLOTS=string.

Here I am looking for a script which compares test.log file ( whose RHS data-types are known prior whether it is digit or string) with test.Ref which is reference file for test.log file. It will be really helpful for me if any of you give some idea about writing this script.

Thanks,
-Shilpa
 
Old 03-29-2010, 02:31 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
What is the output required ?
 
Old 03-29-2010, 02:42 AM   #3
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,432

Rep: Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192
Does diff not do what you want? eg.

Code:
diff test.log test.Ref
Evo2.
 
  


Reply

Tags
columns, compare, different, file, from, two


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compare $php variable to indexed distinct mysql columns secretlydead Programming 1 02-18-2008 10:48 PM
Removing columns from a file using `sed` indiancosmonaut Programming 6 10-04-2007 12:42 AM
how to append columns form a column file in another file adam_blackice Programming 4 09-17-2007 11:33 PM
how to exchange two columns of a file jackk294 Programming 8 07-11-2006 11:37 PM
Reading in data in columns from a file (C++) Nylex Programming 4 03-08-2006 05:55 PM


All times are GMT -5. The time now is 05:11 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration