LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help me (https://www.linuxquestions.org/questions/linux-newbie-8/help-me-734916/)

Rajnish Sharma 06-23-2009 01:31 AM

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

jdkaye 06-23-2009 01:54 AM

Is this homework by any chance?
jdk

Rajnish Sharma 06-24-2009 11:40 PM

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

Wim Sturkenboom 06-25-2009 01:22 AM

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.


All times are GMT -5. The time now is 11:27 PM.