Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  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
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
Is this homework by any chance?
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: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

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.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:57 AM.

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