Filtering maximum valued file.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Filtering maximum valued file.
# 1  
Old 01-24-2012
Filtering maximum valued file.

Hi
Code:
a.123
a.136
a.146
B.124
B.39
C.24

I have the files in above format ;

I want to list out the files which has maximum value in each group as pipe delimited :
Code:
a.146|B.124|C.24

Please help me in this.
Thanks
# 2  
Old 01-24-2012
Try:
Code:
awk -F"." '{if (a[$1]<$2) a[$1]=$2}END{for (i in a) printf i"."a[i]"|";print}' file

Shorter:
Code:
sort -t"." -nrk2 file | nawk -F"." '{ORS="|"}!a[$1]++'


Last edited by bartus11; 01-24-2012 at 08:19 AM..
This User Gave Thanks to bartus11 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

If the 1th column of file f1 and file f2 is the same, then export those line with maximum string of

please help to write a awk command-line programs to achieve the following functions: Thank in advance. Requeset Description: compare two files f1 and f2, export to file f3: 1 Delete duplicate rows of in file f1 and file f2 2 If the 1th column of file f1 and file f2 is the same, then export... (1 Reply)
Discussion started by: weichanghe2000
1 Replies

2. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

3. Solaris

Split file based on multi valued attributes

Hi, I am new to shell scripting. I have a file which has multi valued attributes. I wanted to split it so that there will be no muliti valued attributes. Example file: "attr1","amv1;amv2;3","bmv1;bmv2","abc","abc1;abc2;abc3" Plz note this is CSV file and ; is the delimiter for multi valued... (7 Replies)
Discussion started by: snukala
7 Replies

4. Linux

maximum file & directories

Dear friends, How many maximum number of files and directories can be created in linux system. Thanks.. (2 Replies)
Discussion started by: karthigayan
2 Replies

5. UNIX for Dummies Questions & Answers

Maximum file size ????

Hi All, - block size of 512KB & every address requires 4 bits - The inode structure contains 10 direct pointers, 1 single indirect, 1 double indirect & 1 triple indirect pointer What could be the possible maximum file size for this system Any guess? I am unable to understand the question... (0 Replies)
Discussion started by: preethgideon
0 Replies

6. UNIX for Dummies Questions & Answers

maximum tar file size?

Is there a reasonable maximum limit for tar file sizes? I want to transfer a pile of files from one server to another but have restricted means, so tarring them first will probably be best... but how big can I go - both for the file format itself and for the operating system (linux) to handle? ... (7 Replies)
Discussion started by: Bobby
7 Replies

7. UNIX for Dummies Questions & Answers

Maximum size of a file in unix

What's the maximum file size supported by unix. (3 Replies)
Discussion started by: nagalenoj
3 Replies

8. Programming

Maximum File Size

Hi, When i checked for the maximum file size on solaris 5.9 the max file size obtained was only 2147483647 and all the further writes to the file which had reached that max size is not added to that file. even i had registered the signal SIGXFSZ, but the signal was not delivered to the... (5 Replies)
Discussion started by: matrixmadhan
5 Replies

9. UNIX for Dummies Questions & Answers

Maximum size of sed file...

The sed -f option (reading sed commands from a file) seems to have a limit of 200 transactions per file. I can't see anything in the man pages about this restriction. I have a file with several thousand sed commands I need to perform (substitutions) - and while I can split the file into... (14 Replies)
Discussion started by: peter.herlihy
14 Replies

10. UNIX for Dummies Questions & Answers

Maximum file name length

Hi folks, Can anybody tell me whether there is any limit on the file name length and directory name length in UNIX. (4 Replies)
Discussion started by: rkkiran
4 Replies
Login or Register to Ask a Question