Reading from a specific line in a loop

Hello All,

Request you to let me know how to do the below urgently..

Requirement

File A Contains:
for i in file A
DEV1
DEV5
STG1
STG5

File B Contains:
for j in file B
DEV1
DEV5
STG1
STG5

take the first value of i and compare with the other values of j - 4 comparisons

take the second value of i and compare with the other values of j - again 4 comparisons which is not required cos...DEV1 has been already compared with DEV 5 and therefore DEV5 need not be compared with DEV1 again...

Therefore we need to have a logic like...

DEV1 should read lines below it in j
DEV5 should only compare lines below it in j
and so on...

and do i implement this logic....how do i tell the inner loop to do this in UNIX..

Please help...

THank you

What you're trying to do is either a homework problem, or else so terribly-defined as to defy any hope of getting a productive answer.

Let's examine the possibilities:
1) Your listed files are the extent of the data: Seriously? You're worried about performance when comparing four entries to four other entries?
2) Your listed files aren't the full extent of the data: You're worried about performance, but you're doing this as a shell script?
3) You're doing line-by-line comparisons: diff
4) You're looking for an entry in one file that doesn't exist in the other: sort | uniq | diff
etc., etc.

Please go into more detail about what you want and we'll be happy to assist, but your current post is doing neither you nor us any good. Lastly, a point of etiquette: "Request you to let me know how to do the below urgently.." is not useful. Unless you're paying for advice, you don't get to set the timetable.

Hey BMDan,

Apologies...for the same..

To clear your doubts..

  1. It is not the performance i am worryin about
  2. I am trying to reduce the number of comparisons as both the files contain the same data
  3. if file a and b have 4 lines each we would be having 16 comparisons...but since file a and b are similar... there would comparisons like line1 = line3 and also line 3 = line1 .. we may have a single comparison rather than both as line1=line3 or line3=line1 both are the same..

Do let me know if there is any way I can implement this...

Thanks and Regards
Kaushik

Thanks folks..

I got it...

Check out this:

http://www.unix.com/shell-programming-scripting/32969-get-line-number.html\#post302096581