The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reading from within the loop --std i/p problem mobydick Shell Programming and Scripting 2 07-11-2008 05:42 PM
reading text file line by line MizzGail Shell Programming and Scripting 6 04-14-2008 03:58 AM
Reading specific part of file guptan UNIX for Dummies Questions & Answers 5 06-30-2005 08:23 AM
reading specific line from file cool_boss2121 Shell Programming and Scripting 10 04-26-2005 06:05 PM
reading files for specific dates siva_jm Shell Programming and Scripting 3 06-08-2004 01:19 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Posts: 13
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Location: BlackMesh Managed Hosting
Posts: 61
Stumble this Post!
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.
Reply With Quote
  #3 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Jul 2008
Posts: 13
Stumble this Post!
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
Reply With Quote
  #4 (permalink)  
Old 07-24-2008
Registered User
 

Join Date: Jul 2008
Posts: 13
Stumble this Post!
Thanks folks..

I got it...

Check out this:

Get line number
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0