LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 06-23-2009, 01:31 AM   #1
Rajnish Sharma
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Help me


Hi All
Plz help me in doing the following task

I have two files FILE A and FILE B
Both files contains two columns
Column1 and Column2

The format is as follows

Column1 Column2
A 1
B 2
C 3


I need to make a script that will do the following

Pick the first line from file A
and compare it with the same name in file 2

For e.g Suppose FILE A contains "A" in 1st column and its value is
1 in column2

So the script will search for "A" in FILE B and it will compare the value of A in FILE B

Three cases are possible
1)FILE B does not contain "A"
2)FILE B contains A but its value mismatches
3)FILE B contains A and has the same value as in FILE A

In this way it will search for all the lines in FILE A and will return the output in a FILE C in the following format


Column1 Value in FILE A VALUE in FILE B REMARK
A 1 1 same
B 2 3 mismatch
C 3 - not found
 
Old 06-23-2009, 01:54 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Is this homework by any chance?
jdk
 
Old 06-24-2009, 11:40 PM   #3
Rajnish Sharma
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Its not homework
Its just a minute part of a big script that I am developing
I dunno how I got stuck out there

Anyways I have resolved the same
Thanks for your support
 
Old 06-25-2009, 01:22 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Next time, please phrase your question a bit different. I also had the feeling that this might have been homework. The main reason is that you
  • did not post anything that you tried
  • did not state with what you are stuck
  • did not provide info about the language (bash, tcl, etc)
  • did not ask for pointers how to solve it but just stated 'I need to make a script that will do the following'
If you would have started with something like 'I don't have any idea where to start' or 'which function can I use to compare files', people will give you some pointers to functions / programs that you can use for it and you can try something. Next you can post what you have and what is not working and people will assist you with the debugging.

Hope this helps for your next question.
 
  


Reply



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



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration