Sponsored Content
Full Discussion: Searching max
Top Forums Shell Programming and Scripting Searching max Post 302860343 by Don Cragun on Saturday 5th of October 2013 04:34:50 PM
Old 10-05-2013
Quote:
Originally Posted by Manu1234567
I guess i need add smth else .....

Code:
sort "/Users/Manu/files/*" | awk '($3 > maxoct3) { maxoct3 = $3; maxoct4 = $4 } $3 ~ maxoct3 && ($4 > maxoct4) { maxoct4 = $4 } END {printf "xxx.xxx.%s.%s\n", maxoct3, maxoct4}' FS=. ips.txt

Moderator's Comments:
Mod Comment We are serious about using CODE tags. Leaving out the code tags makes the above (poorly formatted single-line) command appear to be a multi-line command with syntax errors.
No, combining bits and pieces of RudiC's suggested code, and CarloM's (or my corrected version of CarloM's) code gives you a hybrid solution that does runs slower and only considers the contents of one file.

I would still suggest my solution (slightly modified to use your new set of files):
Code:
awk -F '[.]' '
$3 > m3 {m3 = $3; m4 = $4; next}
$3 == m3 && $4 > m4 {m4 = $4}
END {print "xxx.xxx." m3 "." m4}
' /Users/Manu/files/*

but I may be biased.

Note that if you did want to sort a list of files in the directory /usrs/Manu/files, you would have to leave off the double quotes in the command:
Code:
sort /Users/Manu/files/*

With the command:
Code:
sort "/Users/Manu/files/*"

it will only sort the single file named * in that directory or produce a file not found diagnostic if that file doesn't exist.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Max I/O Size

My HP-UX 11.0 system is supporting an Oracle database. I have found a number of references on the Net to the "Max I/O size" in relation to setting Oracle parameters. How can I tell what my max i/o size is? I originally made the assumption that it was referring to my stripe size but now I think... (1 Reply)
Discussion started by: keelba
1 Replies

2. Shell Programming and Scripting

Finding max value

My code below is supposed to find which company had the most business and then print the appropriate fields from another file which are the companies ID number and name. I can loop through awk and display all the total amount of business for each company but I need help in only printing out the... (1 Reply)
Discussion started by: Enigma23
1 Replies

3. Shell Programming and Scripting

How i get the max value of a row?

I have a file like: <word> 5 <word> 3 <word> 5 <word> 2 <word> 6 <word> 8 <word> 12 and i need to know the max value of the second column, in this case 12. Plz help me! Actually i need the TOTAL, AVERANGE and MAX VALUE and i'm using this in... (10 Replies)
Discussion started by: Lestat
10 Replies

4. Shell Programming and Scripting

max value

Hi All, I want to choose the maximum value from a column values. eg - 234 23 567 43 2456 5 678 8978 from thses values how to choose the max value ? thanks. roger. (3 Replies)
Discussion started by: Nayanajith
3 Replies

5. Shell Programming and Scripting

Max NO of parameters

1> Can anyone tell me what is the maximum no of parameters that can be passed to a file 2> i have 100 files amongst which in 500 files i have a string which needs to be searched how would get the names of those files. (1 Reply)
Discussion started by: Shivdatta
1 Replies

6. Programming

int *ptr + max possible value

From reading my C book, Im aware that the integers have a maximum value which depends on what type of processor you are using (since they use 16-bit or 32-bit instructions). Now I know pointers are very flexible, since they can reference anything, but in the case of integer pointers, can they... (4 Replies)
Discussion started by: JamesGoh
4 Replies

7. Linux

max password is blank

Hi All, I have this userid: # cat /etc/shadow | grep mysql mysql:$1$O12345678901234/.:123456:0::14::: Max password expiration is blank. What does it mean? If it's like this below mysql:$1$O12345678901234/.:123456:0:99999:14::: then there's no expiration. Thanks in advance for... (1 Reply)
Discussion started by: itik
1 Replies

8. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

9. Shell Programming and Scripting

Get the MAX value out of a column

I've the following data set. I would like to look at the column 3 and only use the rows which has the max value for column 3 Can we use the awk or sed to achieve it. 10 2 10 100 11 2 20 100 12 2 30 100 13 2 30 100 14 ... (7 Replies)
Discussion started by: rudoraj
7 Replies
All times are GMT -4. The time now is 01:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy