Finding Minimum in a Series


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding Minimum in a Series
# 1  
Old 12-05-2011
Finding Minimum in a Series

I have two LARGE files of data more than 20,000 line each, file-1 and file-2, and I wish to do the following if possible:

file-1
Code:
1 2 5 7 9
2 4 6 3 8 9
4 6 8 9 3 2 1 3
1 2
.
.
.

file-2
Code:
1 2 3
2 5 7
5 7 3
7 9 4
.
.
.

The goal is to write a script that will loop in each line of the first line and find the minimum value between each line's series.

e.g.,
After reading the first line from file-1 "1 2 5 7 9" it will check in file two for the minimum as follows:
Between 1 & 2 = 3
Between 2 & 5 = 7
Between 5 & 7 = 3
Between 7 & 9 = 4

And then it takes min(3,7,3,4) = 3.
Note: the lengths of file-1's lines are NOT the same.

Last edited by fpmurphy; 12-05-2011 at 11:48 PM..
# 2  
Old 12-05-2011
So what happens when line 2 of file-1 is read?
# 3  
Old 12-05-2011
Looks very much like home work to me...
This User Gave Thanks to vbe For This Post:
# 4  
Old 12-05-2011
Yes, file-2 will have data for all lines in file-1. So for line 2 "2 4 6 3 8 9" in file-1, file-2 will have something like this:

2 4 1
4 6 2
6 3 1
3 8 4
8 9 4

And then it takes min(1,2,1,,4,4) = 1.

---------- Post updated at 11:46 AM ---------- Previous update was at 11:42 AM ----------

Quote:
Originally Posted by vbe
Looks very much like home work to me...

Don't you think that you are annoying? THERE ARE PEOPLE WHO HAVE THE ABILITY TO ASK EVEN BETTER THAN PROFESSORS. SO DON"T INSULT OTHERS WITH YOUR WORDS OKAY. I"M NOT FROM THOSE YOU THINK [KEEP THIS IN MIND].
# 5  
Old 12-05-2011
So, is it homework?
This User Gave Thanks to CarloM For This Post:
# 6  
Old 12-05-2011
This was the first time he was asked AND NEVER answered, now he is at ONE point of permanent ban...
Don't ask me to come back on my decision...
This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding minimum maximum and average

I am trying to find the minimum maximum and average from one file which has values Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds. Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds. Received message from... (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

2. Shell Programming and Scripting

Find minimum value different from zero

Hello, I have this file file1.csv Element1;23-10-2012;1,450;1,564;1,428 Element2;23-10-2012;1,448;1,565;1,427 Element3;23-10-2012;1,453;1,570;1,424 Element4;23-10-2012;1,428;1,542;1,405 Element5;23-10-2012;1,461;;1,453 Element6;23-10-2012;1,438;1,555;1,417... (6 Replies)
Discussion started by: saba01
6 Replies

3. UNIX for Dummies Questions & Answers

Finding specific series of strings or characters

After spending sometime playing around with my script I just cannot get it to do what I want. So I decided to ask. My file looks something like this: I am using the following code to extract sequences that contain dashes awk '/^>/{id=$0;next}{if (match($1,"-")) print id "\n" $0}' infile ... (17 Replies)
Discussion started by: Xterra
17 Replies

4. Shell Programming and Scripting

Finding repitition of series

Dear friends, hello to everyone. I am new to this forum. I have a set of data where I need to find the repitition of series as below data format: 0001230000456000001230000456 each digit can be separated by any delimeter I need to find out the starting point (index) of '123' and '456' I... (2 Replies)
Discussion started by: gjarms
2 Replies

5. Shell Programming and Scripting

Finding minimum value

Hi All, I have multiple files which contains 5 columns and multiple rows..... I want to calculate the minimum value of column 5th, if column 2 is MET, till column 1 comes to the next number. Also it must skip the condition similar to 1st line where column number 1 and 3 are same and... (9 Replies)
Discussion started by: CAch
9 Replies

6. Shell Programming and Scripting

Finding minimum value out of specific rows

Hi all, I am having multiple files with the pattern given below: I need to find the minimum value of 5th column if column 1 is x and 2nd column is awh or vbn or ... (20 different strings). the output must be like: Kindly help me to figure out this prob.... Thanks in... (4 Replies)
Discussion started by: CAch
4 Replies

7. Shell Programming and Scripting

Find the minimum value

Hi there I have generated a column containing 100.000 values. Sample: 94.971 101.468 73.120 100.601 102.329 I need to find the minimum value in this file and I must know which row it is in (no sorting). I hope you can help! Thanks! (16 Replies)
Discussion started by: cno
16 Replies

8. Shell Programming and Scripting

Finding Minimum value per Row range of data

Here is an example of a file I am working with: C 4704 CB 1318 ASP 115 BGRF 1 weak 0.0% 4.33 C 4720 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.71 O 4723 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.48 O 4723 CG 1321 ASP 115 BGRF 1 weak 0.0% 4.34... (3 Replies)
Discussion started by: userix
3 Replies

9. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

10. UNIX for Dummies Questions & Answers

Minimum RAM

Can anyone tell me the minimum ram requirements for suse 6.1 & mdk9 please? Will they accept edo ram? (3 Replies)
Discussion started by: onestepto
3 Replies
Login or Register to Ask a Question