04-08-2013
@sathyaonnuix: You're on the right track. Why don't you try to assign $1 to an array and increment that array's index if $3==max? On new max, reset the index to 1.
@pamu: your proposal yields XYZf with the sample given.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, i have a file with numbers in it and i was wondering if there's a script i could use to find the max number and have that printed to a new file?
example a.txt
18
26
47
34
27
so find the max number in a.txt and print it to b.txt.
Thanks! (17 Replies)
Discussion started by: moonbaby
17 Replies
2. Shell Programming and Scripting
Is there a simple way of calculating the max number in a set of variables, so
a=1
b=3
c=6
d=30
something that says
e=max($a, $b, $c, $d)
I've found a way to do it using:
a="1"
b="3"
c="5"
d="50"
if ;
then
t=$a
else (3 Replies)
Discussion started by: unclecameron
3 Replies
3. Shell Programming and Scripting
FILE_NAME VER TYPE DELETED_DATE CREATED_DATE SIZE LOCATION
hello 1 d 2010-08-09 2010-08-09 4096 /home/xxxxx/project/
hello 2 d 2010-08-09 2010-08-09 4096 /home/xxxxx/project/
hello 3 d 2010-08-09 2010-08-09 4096 /home/xxxxx/project/
hello 4 d 2010-08-09 2010-08-09 4096 /home/xxxxx/project/
... (4 Replies)
Discussion started by: classic
4 Replies
4. Shell Programming and Scripting
Input_ File :
2 3 4 5
1 1 0 1
2 1 -1 1
2 1 3 1
3 1 4 1
6 5 6 6
6 6 6 7
6 7 6 8
5 8 6 7
Desired output :
2 3 4 5
-1 1 4 1
6 5 6 8
5 8 6 7 (3 Replies)
Discussion started by: vasanth.vadalur
3 Replies
5. Shell Programming and Scripting
Hello Experts,
I have got a txt files which has multiple columns, I want to get the max, min and diff (max-min) for each column in the same txt file. Example:
cat file.txt
a 1 4
b 2 5
c 3 6
I want ouput like:
cat file.txt
a 1 4
b 2 5
c 3 6
Max 3 6
Min 1 4
Diff 2 2
awk 'min=="" ||... (4 Replies)
Discussion started by: dixits
4 Replies
6. Shell Programming and Scripting
I have a file about cpu load like this (the first column is time, the second column is cpu load):
11:34:01 0.10
11:34:37 0.05
11:35:13 0.03
11:35:59 0.06
11:38:00 0.02
11:38:09 0.17
11:39:48 0.06
I need to find the max value of the second column so I write the script as follows
max=0... (5 Replies)
Discussion started by: muffle
5 Replies
7. Shell Programming and Scripting
hi,
i have a string
" 00000069 ThreadMonitor W WSVR0606W: Thread "WebContainer : 43|null" (00000069) was previously rep
orted to be hung but has completed. It was active for approximately 47533430 milliseconds. There is/are 43 thread(s) in tot
al in the server that still may be hung."
... (4 Replies)
Discussion started by: lovelysethii
4 Replies
8. UNIX for Dummies Questions & Answers
Hi folks,
I am very new to awk. I have what is probably a very simple question. I'm trying to get the max value of column 1, but also print column 2. My data looks like this:
0.044|2000-02-03 14:00:00
5.23|2000-02-03 05:45:00
5.26|2000-02-03 11:15:00
0|2000-02-01 18:30:00
So in this case... (2 Replies)
Discussion started by: amandarobe
2 Replies
9. Shell Programming and Scripting
I need to find the max/min of columns 1 and 2 of a 2 column file what contains the special character ">".
I know that this will find the max value of column 1.
awk 'BEGIN {max = 0} {if ($1>max) max=$1} END {print max}' input.file
But what if I needed to ignore special characters in the... (3 Replies)
Discussion started by: ncwxpanther
3 Replies
10. Shell Programming and Scripting
I need to find the max value of all columns except the 1st column and print the answer along with the 1st column.
Input
123xyz 0 0 1 2 0 0 0 0 0 0 0
234xyz 0 0 0 0 0 0 0 0 0 0 0
345xyz 0 0 1 0 0 0 ... (8 Replies)
Discussion started by: ncwxpanther
8 Replies