Sponsored Content
Top Forums Shell Programming and Scripting How to only display lines where a field has the highest number? Post 302442764 by Glyn_Mo on Thursday 5th of August 2010 11:22:11 AM
Old 08-05-2010
Question How to only display lines where a field has the highest number?

Hello

Wondering if anybody can advise me how I can sort the below file so it only displays lines with the latest versions of an object? As you'll see some of the scripts listed in my file have more than one version number (version number is after the file extension). E.g. cdm_bri.pkb has versions 1 - 6 listed I only want to see the line showing verson 6. I've searched the forum for similar threads, but haven't been able to find what I'm looking for.

Many thanks
Glyn

Code:
 
breach_repetitions_pop.sql-1           85820       SRDP_BREACHES/1
breach_repetitions_pop.sql-2           86628       SRDP_BREACHES/1
breach_repetitions.tab-1               85820       SRDP_BREACHES/1
breach_repetitions.tab-2               86628       SRDP_BREACHES/1
breach_reporting_orgs_pop.sql-1        85820       SRDP_BREACHES/1
breach_reporting_orgs_pop.sql-2        86628       SRDP_BREACHES/1
breach_reporting_orgs.tab-1            85820       SRDP_BREACHES/1
breach_reporting_orgs.tab-2            86628       SRDP_BREACHES/1
breach_severities_pop.sql-1            85820       SRDP_BREACHES/1
breach_severities_pop.sql-2            86628       SRDP_BREACHES/1
breach_severities.tab-1                85820       SRDP_BREACHES/1
breach_severities.tab-2                86628       SRDP_BREACHES/1
breaches_br_iu.trg-1                   85820       SRDP_BREACHES/1
breaches_br_iu.trg-2                   86628       SRDP_BREACHES/1
breaches_fk.con-2                      85820       SRDP_BREACHES/1
breaches_fk.con-3                      86628       SRDP_BREACHES/1
breaches_qry_api_pkg.pkb-3             85821       SRDP_BREACHES/1
breaches_qry_api_pkg.pkb-4             87266       SRDP_BREACHES/1
breaches_qry_api_pkg.pks-3             85821       SRDP_BREACHES/1
breaches_qry_api_pkg.pks-4             87266       SRDP_BREACHES/1
breaches_upd_api_pkg.pkb-1             87266       SRDP_BREACHES/1
breaches_upd_api_pkg.pks-1             87266       SRDP_BREACHES/1
breaches.tab-2                         85820       SRDP_BREACHES/1
breaches.tab-3                         86628       SRDP_BREACHES/1
cdm_bes.pkb-3                          85821       SRDP_BREACHES/1
cdm_bes.pkb-4                          86589       SRDP_BREACHES/1
cdm_bes.pkb-5                          87101       SRDP_BREACHES/1
cdm_bes.pkb-6                          87152       SRDP_BREACHES/1
cdm_bes.pks-3                          85821       SRDP_BREACHES/1
cdm_bes.pks-4                          86589       SRDP_BREACHES/1
cdm_bilp.pkb-1                         85821       SRDP_BREACHES/1
cdm_bilp.pkb-2                         86589       SRDP_BREACHES/1
cdm_bilp.pkb-3                         87017       SRDP_BREACHES/1
cdm_bilp.pks-1                         85821       SRDP_BREACHES/1
cdm_bilp.pks-2                         86589       SRDP_BREACHES/1
cdm_bre.pkb-3                          85821       SRDP_BREACHES/1
cdm_bre.pkb-4                          87160       SRDP_BREACHES/1
cdm_bre.pkb-5                          87171       SRDP_BREACHES/1
cdm_bre.pks-3                          85821       SRDP_BREACHES/1
cdm_bre.pks-4                          87171       SRDP_BREACHES/1
cdm_bri.pkb-1                          85821       SRDP_BREACHES/1
cdm_bri.pkb-2                          87017       SRDP_BREACHES/1
cdm_bri.pkb-3                          87174       SRDP_BREACHES/1
cdm_bri.pkb-4                          87180       SRDP_BREACHES/1
cdm_bri.pkb-5                          87184       SRDP_BREACHES/1
cdm_bri.pkb-6                          87260       SRDP_BREACHES/1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find the highest number in the file

Hi, I have a file a.txt and it has values in it Eg :- I need to read through the file and find the number that is the greatest in them all. Can any one assit me on this. Thanks (30 Replies)
Discussion started by: systemali
30 Replies

2. UNIX for Dummies Questions & Answers

display lines after a particular line number

I have a file that has 1k lines and i want to print all the lines after 900th line. an 2)I want to move files f1 ,f2,f3,f4 to p1,p2,p3,p4 Please give me the commands. Thanx in adv. (6 Replies)
Discussion started by: rajashekar.y
6 Replies

3. Shell Programming and Scripting

How to match all array contents and display all highest matched sentences in perl?

Hi, I have an array with 3 words in it and i have to match all the array contents and display the exact matched sentence i.e all 3 words should match with the sentence. Here are sentences. $arr1="Our data suggests that epithelial shape and growth control are unequally affected depending... (5 Replies)
Discussion started by: vanitham
5 Replies

4. Shell Programming and Scripting

Displaying lines of a file which have the highest number?

Hello Wondering if anybody may be able to advise on how I can filter the contents of the following file: <object_name>-<version> <Instance> GM_GUI_code.fmb-4 1 GM_GUI_code.fmb-5 1 GM_GUI_code.fmx-4 ... (7 Replies)
Discussion started by: Glyn_Mo
7 Replies

5. Shell Programming and Scripting

Extract the highest number out

Hi Gurus, I've using HPUX B.11.23 U ia64 with shell = sh. I've been having some problem get the highest number of this script. Actually I wanted to get the highest number from this listing (TEST123 data and based on this highest number, there will be email being sent out. For example,... (6 Replies)
Discussion started by: superHonda123
6 Replies

6. UNIX Desktop Questions & Answers

How to display only the lines from a file which do not contain a given number

a. How do I display the content of the file containing what Ive merged using a filter which would display only the lines of the file which don't contain number, for example 3 or 6. (3 Replies)
Discussion started by: herberwz
3 Replies

7. UNIX for Advanced & Expert Users

query display number lines or records present in file only numeric value -without filename

Hi all Thanks in advance........... Please help me for this issue............ I have a file it has 11 records . I used the command like .... >$ wc -l file 11 file I'm getting output like 11 file (no.of records along with filename) here my requirement is, I want to display only... (3 Replies)
Discussion started by: ksrivani
3 Replies

8. Shell Programming and Scripting

Only print the entries with the highest number?

Just want to say this is great resources for all thing Unix!! cat tmp.txt A 3 C 19 A 2 B 5 A 1 A 0 C 13 B 9 C 1 Desired output: A 3 B 9 C 19 The following work but I am wondering if there is a better way to do it: (4 Replies)
Discussion started by: chirish
4 Replies

9. Shell Programming and Scripting

Printing uniq first field with the the highest second field

Hi All, I am searching for a script which will produce an output file with the uniq first field with the second field having highest value among all the duplicates.. The output file will produce only the uniqs which are duplicate 3 times.. Input file X 9 B 5 A 1 Z 9 T 4 C 9 A 4... (13 Replies)
Discussion started by: ailnilanjan
13 Replies

10. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies
look(1) 						      General Commands Manual							   look(1)

NAME
look - Finds lines in a sorted list SYNOPSIS
look [-df] [-tcharacter] string [file] The look command prints all lines in a sorted file that begin with string. OPTIONS
Uses dictionary order; only letters, digits, tabs, and spaces are used in comparisons. Searches without regard to case; treats uppercase and lowercase as equivalent. Ignores character and characters following it in the search string. If you specify look -tC ABCDE, the string ABCDE would become (in effect) AB, with CDE being ignored. This option is primarily for shell scripts, in which more than one string is being processed. DESCRIPTION
If no file is specified, look searches in the system word list /usr/share/dict/words, with the options -df assumed by default. The look command uses binary search. The -d and -f options affect comparisons as in sort. NOTES
In order to use the -f option, you must first sort file with the sort -f command; otherwise, look displays only lowercase items. If you do not specify -f, but specify a file (such as /usr/share/dict/words) that has been sorted with sort -f, look may not produce any output. EXAMPLES
To search a sorted file called sortfile for all lines that begin with the string as, enter: look as sortfile To search the system word list for all words beginning with smi, enter: look smi This might result in: smile smirk smith smithereens Smithfield Smithson smithy smitten FILES
System word list. SEE ALSO
Commands: grep(1), sort(1), spell(1) look(1)
All times are GMT -4. The time now is 03:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy