Visit Our UNIX and Linux User Community


Need to show highest version line from the list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to show highest version line from the list
# 1  
Old 05-13-2016
Linux Need to show highest version line from the list

Hi All,

Need help here, can you tell me the syntax to line grep the highest file version?
Code:
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/
        0  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/seatMap/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/loyaltyManagement/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryBook/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sessioncontext/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryShop/
        0  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/soapenvelope/
        0  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/
     9558  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v16_0.xsd
     9558  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v15_0.xsd
     9532  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v14_0.xsd
     9532  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v13_0.xsd
     9390  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v12_1.xsd
     9390  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v12_0.xsd
     9437  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v11_0.xsd
     9437  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v10_0.xsd
     9127  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v9_0.xsd
     9127  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v8_0.xsd
     9127  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v7_0.xsd
     9099  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v5_0.xsd
     8761  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v4_1.xsd
     8761  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v4_0.xsd
     8761  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v3_0.xsd
     8862  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v2_1.xsd
     8626  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v2_0.xsd
     8640  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airprice/AirPrice_v1_0.xsd
   256197  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v11_0.xsd
   255873  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v10_0.xsd
   253733  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v9_0.xsd
   252399  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v8_0.xsd
   254109  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v7_0.xsd
   250705  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v6_0.xsd
   250705  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v5_0.xsd
   244528  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v4_1.xsd
   243849  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v4_0.xsd
   239140  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v3_0.xsd
   238372  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v2_1.xsd
   254429  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v12_0.xsd
   253257  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v12_1.xsd
   255575  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v13_0.xsd
   255116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v14_0.xsd
   255376  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v15_0.xsd
   257288  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v16_0.xsd
   237674  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v1_0.xsd
   237922  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/air/Air_v2_0.xsd
     7463  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v9_0.xsd
     7448  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v8_0.xsd
     7468  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v10_0.xsd
     7468  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v11_0.xsd
     7302  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v12_0.xsd
     7302  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v12_1.xsd
     7302  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v13_0.xsd
     7329  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v14_0.xsd
     7329  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v15_0.xsd
     7329  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v16_0.xsd
    14852  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v1_0.xsd
    15295  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v2_0.xsd
    15309  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v2_1.xsd
    15295  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v3_0.xsd
     6453  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v4_0.xsd
     7448  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v5_0.xsd
     7448  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v6_0.xsd
     7448  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sharedbusinessservices/SharedBusinessServices_v7_0.xsd
    34915  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v16_0.xsd
    34600  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v15_0.xsd
    34745  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v14_0.xsd
    34745  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v13_0.xsd
    32541  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v12_1.xsd
    32087  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v12_0.xsd
    32395  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v11_0.xsd
    32395  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v10_0.xsd
    30912  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v9_0.xsd
    30912  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v8_0.xsd
    29575  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v7_0.xsd
    28029  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v6_0.xsd
    25766  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v5_0.xsd
    25766  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v4_0.xsd
    25144  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v3_0.xsd
    22447  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v2_0.xsd
    21020  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/airshop/AirShop_v1_0.xsd
     3144  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v9_0.xsd
     3144  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v8_0.xsd
     3144  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v7_0.xsd
     4443  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v6_0.xsd
     4443  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v5_0.xsd
     4443  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v4_0.xsd
     4443  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v3_0.xsd
     4359  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v2_0.xsd
     4359  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v1_0.xsd
     3021  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v16_0.xsd
     3021  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v15_0.xsd
     3021  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v14_0.xsd
     3021  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v13_0.xsd
     3021  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v12_1.xsd
     2968  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v12_0.xsd
     3023  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v11_0.xsd
     3023  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/airfarerules/AirFarerules_v10_0.xsd
    23867  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/seatMap/SeatMap_v1_0.xsd
    21557  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/seatMap/SeatMap_v2_0.xsd
    21566  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/seatMap/SeatMap_v3_0.xsd
     5024  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/loyaltyManagement/LoyaltyManagement_v1_1.xsd
    26736  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryBook/AncillaryAirBook_v1_0.xsd
    27558  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryBook/AncillaryAirBook_v2_0.xsd
    27879  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryBook/AncillaryAirBook_v3_0.xsd
    31593  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryBook/AncillaryAirBook_v4_0.xsd
     1724  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/sessioncontext/SessionContext_v1.xsd
   126888  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v6_0.xsd
   128678  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v7_0.xsd
   128678  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v8_0.xsd
   128701  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v9_0.xsd
   129485  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v10_0.xsd
   128904  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v11_0.xsd
   127318  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v12_0.xsd
   127100  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v12_1.xsd
   127318  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v13_0.xsd
   127039  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v14_0.xsd
   127103  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v15_0.xsd
   127175  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v16_0.xsd
   121785  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v1_0.xsd
   126355  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v2_0.xsd
   126902  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v2_1.xsd
   126074  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v3_0.xsd
   126120  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v4_0.xsd
   126888  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/common/Common_v5_0.xsd
     4329  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryShop/AncillaryShop_v1_0.xsd
     4534  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryShop/AncillaryShop_v2_0.xsd
     4629  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryShop/AncillaryShop_v3_0.xsd
     4629  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/ancillaryShop/AncillaryShop_v4_0.xsd
     6249  04-05-2016 07:59   lib/SBSSchemaProject.jar/schemas/soapenvelope/SoapEnvelope.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v7_0.xsd
    31334  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v8_0.xsd
    31334  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v9_0.xsd
    31341  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v10_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v11_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v12_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v12_1.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v13_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v14_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v15_0.xsd
    30666  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v16_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v1_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v2_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v3_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v4_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v5_0.xsd
    31116  04-05-2016 08:00   lib/SBSSchemaProject.jar/schemas/rail/Rail_v6_0.xsd

Any lead would be a great help.

Thanks

Last edited by jim mcnamara; 05-13-2016 at 08:57 AM..
# 2  
Old 05-13-2016
Untested but you get the idea...

Code:
ls -R lib/SBSSchemaProject.jar/schemas/ | perl -ne '($schema,$major,$minor)=$_=~/\/(\w+)_v(\d+)_9\d+).xsd$/;if (($major > $max_major)||(($major == $max_major{$schema}) && ($minor>$max_minor{$schema}){$max{$schema}=$_;$max_major{$schema}=$major;$max_minor{$schema}==$minor;}END{for $schema (keys %max){print "$max{$schema}\n";}}' -

This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 05-14-2016
Hi 100rin,
Welcome to the UNIX & Linux Forums.

What operating system and shell are you using?

From the input, you showed us in post #1 in this thread, what output are you hoping to produce? Are you just looking for 16_0 (the highest version number in the list of files shown), or are you looking for the pathname of each file set with a filename matching the ERE V[0-9]+_[0-9]+.xsd$ with the highest version number for each file set?

Are you looking for version numbers in a file containing the data you showed us, or are you looking for version numbers on files contained in a file hierarchy? (If in a file hierarchy; which directory is the root of that hierarchy?)

For the output, are you looking for just the number, a filename, a pathname, or ls -l format output for the pathname of the file?

Previous Thread | Next Thread
Test Your Knowledge in Computers #933
Difficulty: Medium
Microcontrollers operating within embedded systems (such as the Raspberry Pi, Arduino, and other similar systems) always have internal hardware to keep track of time.
True or False?

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk print line with highest value

grepping on a value but then want to print only those lines that have the highest value in the 4th column log text text R59FJ log text text R63FT log text text R60JX log1 text text R63EA log1 text text R60JX desired output log text text R63FT log1 text text R63EAtried this but not getting... (2 Replies)
Discussion started by: jimmyf
2 Replies

2. Shell Programming and Scripting

Print whole line with highest value from one column

Hi, I have a little issue right now. I have a file with 4 columns test0000002,10030010330,c_,218 test0000002,10030010330,d_,202 test0000002,10030010330,b_,193 test0000002,10030010020,c_,178 test0000002,10030010020,b_,170 test0000002,10030010330,a_,166 test0000002,10030010020,a_,151... (3 Replies)
Discussion started by: Ebk
3 Replies

3. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

4. Shell Programming and Scripting

Parse line based on highest value

Hello, Does anyone know how to parse whole line that has highest value in last column (c12), based on the string in column 6 (column VIRUS) INPUT: 5 7 4 8 3 VIRUS1 5 5 HUMAN1 8 4 100 6 9 7 2 6 VIRUS1 6 0 HUMAN2 6 2 80 9 6 7 3 7 VIRUS1 9 7 HUMAN3 5 9 70 8 5 3 8 6 VIRUS2 8 6 HUMAN4 8 6 95... (3 Replies)
Discussion started by: narachaid
3 Replies

5. Shell Programming and Scripting

Need to print duplicate row along with highest version of original

There are some duplicate field on description column .I want to print duplicate row along with highest version of number and corresponding description column. file1.txt number Description === ============ 34567 nl21a00is-centerdb001:ncdbareq:Error in loading init 34577 ... (7 Replies)
Discussion started by: vijay_rajni
7 Replies

6. Shell Programming and Scripting

Filtering out duplicates with the highest version number

Hi, I have a huge text file with filenames which which looks like the following ie uniquenumber_version_filename: e.g. 1234_1_xxxx 1234_2_vfvfdbb 343333_1_vfvfdvd 2222222_1_ggggg 55555_1_xxxxxx 55555_2_vrbgbgg 55555_3_grgrbr What I need to do is examine the file, look for... (4 Replies)
Discussion started by: mantis
4 Replies

7. Shell Programming and Scripting

Printing highest value from a list

Hi all, I'm trying to get the item with the maximum value, and was wondering if someone can help me with it. Heres my input file: apples 15 books 15 books 17 pens 12 pens 15 umbrella 13Here's what my output file should look like: apples 15 books 17 pens 15 umbrella 13 Can... (2 Replies)
Discussion started by: r4v3n
2 Replies

Featured Tech Videos