Strange sort -r results


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Strange sort -r results

Hi Folks -


I have this file that looks like this:

Code:
 outbox/logs/Client_1042.log
 outbox/logs/Client_941.log
 outbox/logs/Client_942.log
 outbox/logs/Client_943.log
 outbox/logs/Client_944.log

And this is my code:
Code:
#!/bin/bash
_OUTBOX_BIN="outbox/logs/"
_NAME="Client"
_TEMP="temp.txt"
_FDMEE_LOG="$(sort -r ${_TEMP} | sed -n "\#${_OUTBOX_BIN}${_NAME}_# {s#.*/##; p; q}").log"

echo $_FDMEE_LOG

And I need it to return the file suffix with the highest numerical value. Therefore it should return 1042 but instead it's returning Client_944.log. Do you know why?


Thanks!

Last edited by Scrutinizer; 11-20-2018 at 01:21 PM.. Reason: quote tags -> code tags
# 2  
Code:
awk -F'[_.]' '{print $(NF-1)}' myFile | sort -rn | head -1

# 3  
Sorry, I only gave am example. Here is the full file I am working with. Getting an error with your suggestion.


It should return "Client_1042.log"


Code:
 AP_Backup 18-09-12.zip
 apr/2018-09-20 09_11_03/2018-09-20 09_11_03.html
 apr/2018-09-20 09_11_03/access_log.zip
 apr/2018-09-21 09_10_57/2018-09-21 09_10_57.html
 apr/2018-09-21 09_10_57/access_log.zip
 apr/2018-09-22 09_10_42/2018-09-22 09_10_42.html
 apr/2018-09-22 09_10_42/access_log.zip
 apr/2018-09-23 09_10_01/2018-09-23 09_10_01.html
 apr/2018-09-23 09_10_01/access_log.zip
 apr/2018-09-24 09_10_13/2018-09-24 09_10_13.html
 apr/2018-09-24 09_10_13/access_log.zip
 apr/2018-09-25 09_10_59/2018-09-25 09_10_59.html
 apr/2018-09-25 09_10_59/access_log.zip
 apr/2018-09-26 09_11_06/2018-09-26 09_11_06.html
 apr/2018-09-26 09_11_06/access_log.zip
 apr/2018-09-27 09_11_09/2018-09-27 09_11_09.html
 apr/2018-09-27 09_11_09/access_log.zip
 apr/2018-09-28 09_17_10/2018-09-28 09_17_10.html
 apr/2018-09-28 09_17_10/access_log.zip
 apr/2018-09-29 09_10_56/2018-09-29 09_10_56.html
 apr/2018-09-29 09_10_56/access_log.zip
 apr/2018-09-30 09_10_39/2018-09-30 09_10_39.html
 apr/2018-09-30 09_10_39/access_log.zip
 apr/2018-10-01 09_10_58/2018-10-01 09_10_58.html
 apr/2018-10-01 09_10_58/access_log.zip
 apr/2018-10-02 09_11_15/2018-10-02 09_11_15.html
 apr/2018-10-02 09_11_15/access_log.zip
 apr/2018-10-03 09_11_09/2018-10-03 09_11_09.html
 apr/2018-10-03 09_11_09/access_log.zip
 apr/2018-10-04 09_11_04/2018-10-04 09_11_04.html
 apr/2018-10-04 09_11_04/access_log.zip
 apr/2018-10-05 09_11_12/2018-10-05 09_11_12.html
 apr/2018-10-05 09_11_12/access_log.zip
 apr/2018-10-06 09_13_52/2018-10-06 09_13_52.html
 apr/2018-10-06 09_13_52/access_log.zip
 apr/2018-10-07 09_11_59/2018-10-07 09_11_59.html
 apr/2018-10-07 09_11_59/access_log.zip
 apr/2018-10-08 09_10_54/2018-10-08 09_10_54.html
 apr/2018-10-08 09_10_54/access_log.zip
 apr/2018-10-09 09_11_26/2018-10-09 09_11_26.html
 apr/2018-10-09 09_11_26/access_log.zip
 apr/2018-10-10 09_11_22/2018-10-10 09_11_22.html
 apr/2018-10-10 09_11_22/access_log.zip
 apr/2018-10-11 09_10_49/2018-10-11 09_10_49.html
 apr/2018-10-11 09_10_49/access_log.zip
 apr/2018-10-12 09_11_17/2018-10-12 09_11_17.html
 apr/2018-10-12 09_11_17/access_log.zip
 apr/2018-10-13 09_11_57/2018-10-13 09_11_57.html
 apr/2018-10-13 09_11_57/access_log.zip
 apr/2018-10-14 09_10_28/2018-10-14 09_10_28.html
 apr/2018-10-14 09_10_28/access_log.zip
 apr/2018-10-15 09_10_33/2018-10-15 09_10_33.html
 apr/2018-10-15 09_10_33/access_log.zip
 apr/2018-10-16 09_11_37/2018-10-16 09_11_37.html
 apr/2018-10-16 09_11_37/access_log.zip
 apr/2018-10-17 09_12_29/2018-10-17 09_12_29.html
 apr/2018-10-17 09_12_29/access_log.zip
 apr/2018-10-18 09_11_48/2018-10-18 09_11_48.html
 apr/2018-10-18 09_11_48/access_log.zip
 apr/2018-10-19 09_12_05/2018-10-19 09_12_05.html
 apr/2018-10-19 09_12_05/access_log.zip
 apr/2018-10-20 09_12_06/2018-10-20 09_12_06.html
 apr/2018-10-20 09_12_06/access_log.zip
 apr/2018-10-21 09_10_39/2018-10-21 09_10_39.html
 apr/2018-10-21 09_10_39/access_log.zip
 apr/2018-10-22 09_11_06/2018-10-22 09_11_06.html
 apr/2018-10-22 09_11_06/access_log.zip
 apr/2018-10-23 09_11_39/2018-10-23 09_11_39.html
 apr/2018-10-23 09_11_39/access_log.zip
 apr/2018-10-24 09_11_44/2018-10-24 09_11_44.html
 apr/2018-10-24 09_11_44/access_log.zip
 apr/2018-10-25 09_11_08/2018-10-25 09_11_08.html
 apr/2018-10-25 09_11_08/access_log.zip
 apr/2018-10-26 09_11_25/2018-10-26 09_11_25.html
 apr/2018-10-26 09_11_25/access_log.zip
 apr/2018-10-27 09_11_17/2018-10-27 09_11_17.html
 apr/2018-10-27 09_11_17/access_log.zip
 apr/2018-10-28 09_10_27/2018-10-28 09_10_27.html
 apr/2018-10-28 09_10_27/access_log.zip
 apr/2018-10-29 09_10_44/2018-10-29 09_10_44.html
 apr/2018-10-29 09_10_44/access_log.zip
 apr/2018-10-30 09_11_17/2018-10-30 09_11_17.html
 apr/2018-10-30 09_11_17/access_log.zip
 apr/2018-10-31 09_11_39/2018-10-31 09_11_39.html
 apr/2018-10-31 09_11_39/access_log.zip
 apr/2018-11-01 09_12_37/2018-11-01 09_12_37.html
 apr/2018-11-01 09_12_37/access_log.zip
 apr/2018-11-02 09_11_40/2018-11-02 09_11_40.html
 apr/2018-11-02 09_11_40/access_log.zip
 apr/2018-11-03 09_14_18/2018-11-03 09_14_18.html
 apr/2018-11-03 09_14_18/access_log.zip
 apr/2018-11-04 09_11_18/2018-11-04 09_11_18.html
 apr/2018-11-04 09_11_18/access_log.zip
 apr/2018-11-05 09_11_19/2018-11-05 09_11_19.html
 apr/2018-11-05 09_11_19/access_log.zip
 apr/2018-11-06 09_15_46/2018-11-06 09_15_46.html
 apr/2018-11-06 09_15_46/access_log.zip
 apr/2018-11-07 09_15_13/2018-11-07 09_15_13.html
 apr/2018-11-07 09_15_13/access_log.zip
 apr/2018-11-08 09_12_04/2018-11-08 09_12_04.html
 apr/2018-11-08 09_12_04/access_log.zip
 apr/2018-11-09 09_12_36/2018-11-09 09_12_36.html
 apr/2018-11-09 09_12_36/access_log.zip
 apr/2018-11-10 09_16_32/2018-11-10 09_16_32.html
 apr/2018-11-10 09_16_32/access_log.zip
 apr/2018-11-11 09_12_30/2018-11-11 09_12_30.html
 apr/2018-11-11 09_12_30/access_log.zip
 apr/2018-11-12 09_25_11/2018-11-12 09_25_11.html
 apr/2018-11-12 09_25_11/access_log.zip
 apr/2018-11-13 09_12_24/2018-11-13 09_12_24.html
 apr/2018-11-13 09_12_24/access_log.zip
 apr/2018-11-14 09_14_43/2018-11-14 09_14_43.html
 apr/2018-11-14 09_14_43/access_log.zip
 apr/2018-11-15 09_12_42/2018-11-15 09_12_42.html
 apr/2018-11-15 09_12_42/access_log.zip
 apr/2018-11-16 09_12_51/2018-11-16 09_12_51.html
 apr/2018-11-16 09_12_51/access_log.zip
 apr/2018-11-17 09_13_23/2018-11-17 09_13_23.html
 apr/2018-11-17 09_13_23/access_log.zip
 apr/2018-11-18 09_12_35/2018-11-18 09_12_35.html
 apr/2018-11-18 09_12_35/access_log.zip
 apr/2018-11-19 09_12_37/2018-11-19 09_12_37.html
 apr/2018-11-19 09_12_37/access_log.zip
 apr/2018-11-20 09_13_06/2018-11-20 09_13_06.html
 apr/2018-11-20 09_13_06/access_log.zip
 Artifact Snapshot.zip
 Backup 18-10-31.zip
 Backup 18-11-05.zip
 Backup 18-11-13.zip
 Backup 18-11-15.zip
 Backup_Friday.zip
 Backup_Wednesday.zip
 data/24720211231.xlsx
 data/24920211231.xlsx
 data/25020211231.csv
 data/25120211231.csv
 data/25420211231.csv
 data/26720180930.dat
 data/26820180930.dat
 data/26920180930.dat
 data/27020180930.dat
 data/27120180930.dat
 data/AClient-Vendor_253.json
 data/AClient-Vendor_255.json
 data/AClient-Vendor_731.json
 data/Client_248.json
 data/Client_291.json
 data/Client_307.json
 data/Client_311.json
 data/Client_692.json
 data/Client_867.json
 data/ClientHolding_1000.dat
 data/ClientHolding_1001.dat
 data/ClientHolding_1002.dat
 data/ClientHolding_1003.dat
 data/ClientHolding_1004.dat
 data/ClientHolding_1007.dat
 data/ClientHolding_1008.dat
 data/ClientHolding_1009.dat
 data/ClientHolding_1010.dat
 data/ClientHolding_1011.dat
 data/ClientHolding_1012.dat
 data/ClientHolding_1013.dat
 data/ClientHolding_1014.dat
 data/ClientHolding_1015.dat
 data/ClientHolding_1016.dat
 data/ClientHolding_1041.dat
 data/ClientHolding_1042.dat
 data/ClientHolding_193_ECM.dat
 data/ClientHolding_194_ECM.dat
 data/ClientHolding_196_ECM.dat
 data/ClientHolding_262_ECM.dat
 data/ClientHolding_263_ECM.dat
 data/ClientHolding_267.dat
 data/ClientHolding_268.dat
 data/ClientHolding_269.dat
 data/ClientHolding_270.dat
 data/ClientHolding_271.dat
 data/ClientHolding_281.dat
 data/ClientHolding_282.dat
 data/ClientHolding_283.dat
 data/ClientHolding_297.dat
 data/ClientHolding_299.dat
 data/ClientHolding_300.dat
 data/ClientHolding_303.dat
 data/ClientHolding_304.dat
 data/ClientHolding_321.dat
 data/ClientHolding_357.dat
 data/ClientHolding_358.dat
 data/ClientHolding_359.dat
 data/ClientHolding_360.dat
 data/ClientHolding_361.dat
 data/ClientHolding_362.dat
 data/ClientHolding_363.dat
 data/ClientHolding_364.dat
 data/ClientHolding_365.dat
 data/ClientHolding_369.dat
 data/ClientHolding_370.dat
 data/ClientHolding_374.dat
 data/ClientHolding_375.dat
 data/ClientHolding_376.dat
 data/ClientHolding_377.dat
 data/ClientHolding_380.dat
 data/ClientHolding_381.dat
 data/ClientHolding_382.dat
 data/ClientHolding_383.dat
 data/ClientHolding_388.dat
 data/ClientHolding_425.dat
 data/ClientHolding_426.dat
 data/ClientHolding_440.dat
 data/ClientHolding_446.dat
 data/ClientHolding_448.dat
 data/ClientHolding_449.dat
 data/ClientHolding_450.dat
 data/ClientHolding_453.dat
 data/ClientHolding_455.dat
 data/ClientHolding_476.dat
 data/ClientHolding_481.dat
 data/ClientHolding_521.dat
 data/ClientHolding_522.dat
 data/ClientHolding_525.dat
 data/ClientHolding_535.dat
 data/ClientHolding_536.dat
 data/ClientHolding_585.dat
 data/ClientHolding_586.dat
 data/ClientHolding_587.dat
 data/ClientHolding_588.dat
 data/ClientHolding_589.dat
 data/ClientHolding_590.dat
 data/ClientHolding_591.dat
 data/ClientHolding_592.dat
 data/ClientHolding_593.dat
 data/ClientHolding_641.dat
 data/ClientHolding_642.dat
 data/ClientHolding_643.dat
 data/ClientHolding_644.dat
 data/ClientHolding_645.dat
 data/ClientHolding_646.dat
 data/ClientHolding_647.dat
 data/ClientHolding_749.dat
 data/ClientHolding_751.dat
 data/ClientHolding_762.dat
 data/ClientHolding_763.dat
 data/ClientHolding_781.dat
 data/ClientHolding_782.dat
 data/ClientHolding_783.dat
 data/ClientHolding_801_ECM.dat
 data/ClientHolding_802_ECM.dat
 data/ClientHolding_803_ECM.dat
 data/ClientHolding_805_ECM.dat
 data/ClientHolding_809_ECM.dat
 data/ClientHolding_810_ECM.dat
 data/ClientHolding_812_ECM.dat
 data/ClientHolding_813_ECM.dat
 data/ClientHolding_815_ECM.dat
 data/ClientHolding_816.dat
 data/ClientHolding_817.dat
 data/ClientHolding_821.dat
 data/ClientHolding_823.dat
 data/ClientHolding_852.dat
 data/ClientHolding_853.dat
 data/ClientHolding_854.dat
 data/ClientHolding_855.dat
 data/ClientHolding_856.dat
 data/ClientHolding_857.dat
 data/ClientHolding_858.dat
 data/ClientHolding_859.dat
 data/ClientHolding_860.dat
 data/ClientHolding_900.dat
 data/ClientHolding_907.dat
 data/ClientHolding_909.dat
 data/ClientHolding_910.dat
 data/ClientHolding_911.dat
 data/ClientHolding_912.dat
 data/ClientHolding_913.dat
 data/ClientHolding_914.dat
 data/ClientHolding_941.dat
 data/ClientHolding_942.dat
 data/ClientHolding_943.dat
 data/ClientHolding_944.dat
 data/ClientHolding_945.dat
 data/ClientHolding_946.dat
 data/ClientHolding_947.dat
 data/ClientHolding_948.dat
 data/ClientHolding_949.dat
 data/ClientHolding_951.dat
 data/ClientHolding_952.dat
 data/ClientHolding_953.dat
 data/ClientHolding_954.dat
 data/ClientHolding_955.dat
 data/ClientHolding_956.dat
 data/ClientHolding_957.dat
 data/ClientHolding_958.dat
 data/ClientHolding_959.dat
 data/ClientHolding_960.dat
 data/ClientHolding_961.dat
 data/ClientHolding_962.dat
 data/ClientHolding_963.dat
 data/ClientHolding_964.dat
 data/ClientHolding_965.dat
 data/ClientHolding_966.dat
 data/ClientHolding_967.dat
 data/ClientHolding_981.dat
 data/ClientHolding_982_ECM.dat
 data/ClientHolding_985.dat
 data/ClientHolding_987.dat
 data/ClientHolding_988.dat
 data/ClientHolding_989.dat
 data/ClientHolding_990.dat
 data/ClientHolding_991.dat
 data/ClientHolding_992.dat
 data/ClientHolding_993.dat
 data/ClientHolding_994.dat
 data/ClientHolding_995.dat
 data/ClientHolding_996.dat
 data/ClientHolding_997.dat
 data/ClientHolding_999.dat
 data/EPBCS Assignment Data_276.dat
 data/EPBCS Assignment Data_277.dat
 data/EPBCS Assignment Data_342.dat
 data/EPBCS Assignment Data_343.dat
 data/EPBCS Assignment Data_344.dat
 data/EPBCS Assignment Data_345.dat
 data/EPBCS Assignment Data_353.dat
 data/EPBCS Assignment Data_366.dat
 data/EPBCS Assignment Data_367.dat
 data/EPBCS Assignment Data_368.dat
 data/EPBCS Assignment Data_420.dat
 data/EPBCS Assignment Data_421.dat
 data/EPBCS Assignment Data_422.dat
 data/EPBCS Assignment Data_423.dat
 data/EPBCS Assignment Data_424.dat
 data/EPBCS Assignment Data_520.dat
 data/EPBCS Assignment Data_546.dat
 data/EPBCS Assignment Data_547.dat
 data/EPBCS Assignment Data_548.dat
 data/EPBCS Assignment Data_561.dat
 data/EPBCS Assignment Data_573.dat
 data/EPBCS Assignment Data_574.dat
 data/EPBCS Assignment Data_575.dat
 data/EPBCS Assignment Data_576.dat
 data/EPBCS Assignment Data_577.dat
 data/EPBCS Assignment Data_578.dat
 data/EPBCS Assignment Data_579.dat
 data/EPBCS Assignment Data_580.dat
 data/EPBCS Assignment Data_581.dat
 data/EPBCS Assignment Data_583.dat
 data/EPBCS Assignment Data_584.dat
 data/EPBCS Employee Metadata_346.dat
 data/EPBCS Employee Metadata_347.dat
 data/EPBCS Employee Metadata_348.dat
 data/EPBCS Employee Metadata_349.dat
 data/EPBCS Employee Metadata_350.dat
 data/EPBCS Employee Metadata_351.dat
 data/EPBCS Employee Metadata_352.dat
 data/EPBCS Employee Metadata_582.dat
 data/FGC_190_ECI.dat
 data/FGC_193_ECI.dat
 data/FGC_196_ECI.dat
 data/FGC_801_ECI.dat
 data/FGC_802_ECI.dat
 data/FGC_803_ECI.dat
 data/FGC_805_ECI.dat
 data/FGC_807_ECI.dat
 data/FGC_808_ECI.dat
 data/FGC_809_ECI.dat
 data/FGC_810_ECI.dat
 data/FGC_812_ECI.dat
 data/FGC_813_ECI.dat
 data/FGC_815_ECI.dat
 data/FGC_982_ECI.dat
 epmapplicationsnapshot.xml
 Export_Expense.zip
 inbox/CPX_ERP_ASSETS/Assets Subledger_Excel Output.csv
 inbox/ERP_FS_Acc_Map.txt
 inbox/ERP_FS_ENT_Map.txt
 inbox/ERP_FS_Prj_Map.txt
 inbox/EXPENSE_TransDet/Account_Analysis.csv
 inbox/HCM_DATA_FILE/DATA_ENTITY_MAPS.txt
 inbox/HCM_DATA_FILE/EPBCS HCM Extract Report_EPBCS HCM Extract Report.csv
 inbox/HCM_DATA_FILE/HCM_DATA_FILE_AcctMaps.txt
 inbox/Metadata/Parent and child value report.csv
 inbox/Metadata/Project Parent Child_Project Parent Child.csv
 inbox/Metadata/Suppliers In System.csv
 inbox/OEP_FS_ERP_GL/OEP_FS_ERP_GL_Accts_102518.txt
 inbox/OEP_FS_ERP_GL/OEP_FS_ERP_GL_AllMaps_102518.txt
 inbox/VENDOR_ERP_AP/AP Report_AP Report(2).csv
 inbox/VENDOR_ERP_AP/AP Report_AP Report.csv
 inbox/VENDOR_ERP_AP/AP Report_AP Report.xlsx
 inbox/VENDOR_ERP_AP/AP Report_AP Report_0927.csv
 inbox/WF_EMP_DIM/SampleHCMDataFile.txt
 mdarouie 18-10-12.zip
 outbox/AClient-Vendor_257.dat
 outbox/AClient-Vendor_259.dat
 outbox/AClient-Vendor_260.dat
 outbox/AClient-Vendor_790.dat
 outbox/AClient-Vendor_791.dat
 outbox/AClient-Vendor_842.dat
 outbox/AClient-Vendor_845.dat
 outbox/AClient-Vendor_847.dat
 outbox/AClient-Vendor_848.dat
 outbox/AClient-Vendor_849.dat
 outbox/AClient-Vendor_851.dat
 outbox/Client_1023.dat
 outbox/Client_1024.dat
 outbox/Client_1025.dat
 outbox/Client_1026.dat
 outbox/Client_290.dat
 outbox/Client_302.dat
 outbox/Client_315.dat
 outbox/Client_316.dat
 outbox/Client_317.dat
 outbox/Client_322.dat
 outbox/Client_355.dat
 outbox/Client_356.dat
 outbox/Client_427.dat
 outbox/Client_428.dat
 outbox/Client_429.dat
 outbox/Client_431.dat
 outbox/Client_432.dat
 outbox/Client_433.dat
 outbox/Client_434.dat
 outbox/Client_435.dat
 outbox/Client_436.dat
 outbox/Client_437.dat
 outbox/Client_438.dat
 outbox/Client_439.dat
 outbox/Client_441.dat
 outbox/Client_442.dat
 outbox/Client_445.dat
 outbox/Client_447.dat
 outbox/Client_461.dat
 outbox/Client_462.dat
 outbox/Client_465.dat
 outbox/Client_466.dat
 outbox/Client_467.dat
 outbox/Client_470.dat
 outbox/Client_472.dat
 outbox/Client_482.dat
 outbox/Client_485.dat
 outbox/Client_684.dat
 outbox/Client_685.dat
 outbox/Client_688.dat
 outbox/Client_690.dat
 outbox/Client_691.dat
 outbox/Client_694.dat
 outbox/Client_696.dat
 outbox/Client_698.dat
 outbox/Client_701.dat
 outbox/Client_703.dat
 outbox/Client_705.dat
 outbox/Client_707.dat
 outbox/Client_723.dat
 outbox/Client_726.dat
 outbox/Client_727.dat
 outbox/Client_728.dat
 outbox/Client_729.dat
 outbox/Client_730.dat
 outbox/Client_732.dat
 outbox/Client_733.dat
 outbox/Client_742.dat
 outbox/Client_755.dat
 outbox/Client_759.dat
 outbox/Client_760.dat
 outbox/Client_761.dat
 outbox/Client_864.dat
 outbox/Client_865.dat
 outbox/Client_891.dat
 outbox/Client_894.dat
 outbox/Client_895.dat
 outbox/Client_896.dat
 outbox/Client_897.dat
 outbox/Client_898.dat
 outbox/Client_899.dat
 outbox/Client_901.dat
 outbox/Client_905.dat
 outbox/Client_906.dat
 outbox/logs/Cloud ERP_982.log
 outbox/logs/Client_1000.log
 outbox/logs/Client_1001.log
 outbox/logs/Client_1002.log
 outbox/logs/Client_1003.log
 outbox/logs/Client_1004.log
 outbox/logs/Client_1005.log
 outbox/logs/Client_1006.log
 outbox/logs/Client_1007.log
 outbox/logs/Client_1008.log
 outbox/logs/Client_1009.log
 outbox/logs/Client_1010.log
 outbox/logs/Client_1011.log
 outbox/logs/Client_1012.log
 outbox/logs/Client_1013.log
 outbox/logs/Client_1014.log
 outbox/logs/Client_1015.log
 outbox/logs/Client_1016.log
 outbox/logs/Client_1021.log
 outbox/logs/Client_1022.log
 outbox/logs/Client_1023.log
 outbox/logs/Client_1024.log
 outbox/logs/Client_1025.log
 outbox/logs/Client_1026.log
 outbox/logs/Client_1028.log
 outbox/logs/Client_1029.log
 outbox/logs/Client_1030.log
 outbox/logs/Client_1031.log
 outbox/logs/Client_1033.log
 outbox/logs/Client_1034.log
 outbox/logs/Client_1035.log
 outbox/logs/Client_1036.log
 outbox/logs/Client_1037.log
 outbox/logs/Client_1038.log
 outbox/logs/Client_1039.log
 outbox/logs/Client_1040.log
 outbox/logs/Client_1041.log
 outbox/logs/Client_1042.log
 outbox/logs/Client_941.log
 outbox/logs/Client_942.log
 outbox/logs/Client_943.log
 outbox/logs/Client_944.log
 outbox/logs/Client_945.log
 outbox/logs/Client_946.log
 outbox/logs/Client_947.log
 outbox/logs/Client_948.log
 outbox/logs/Client_949.log
 outbox/logs/Client_950.log
 outbox/logs/Client_951.log
 outbox/logs/Client_952.log
 outbox/logs/Client_953.log
 outbox/logs/Client_954.log
 outbox/logs/Client_955.log
 outbox/logs/Client_956.log
 outbox/logs/Client_957.log
 outbox/logs/Client_958.log
 outbox/logs/Client_959.log
 outbox/logs/Client_960.log
 outbox/logs/Client_961.log
 outbox/logs/Client_962.log
 outbox/logs/Client_963.log
 outbox/logs/Client_964.log
 outbox/logs/Client_965.log
 outbox/logs/Client_966.log
 outbox/logs/Client_967.log
 outbox/logs/Client_981.log
 outbox/logs/Client_983.log
 outbox/logs/Client_984.log
 outbox/logs/Client_985.log
 outbox/logs/Client_986.log
 outbox/logs/Client_987.log
 outbox/logs/Client_988.log
 outbox/logs/Client_989.log
 outbox/logs/Client_990.log
 outbox/logs/Client_991.log
 outbox/logs/Client_992.log
 outbox/logs/Client_993.log
 outbox/logs/Client_994.log
 outbox/logs/Client_995.log
 outbox/logs/Client_996.log
 outbox/logs/Client_997.log
 outbox/logs/Client_998.log
 outbox/logs/Client_999.log
 outbox/MDM_Client - Custom_632.dat
 outbox/MDM_Client - Custom_683.dat
 outbox/MDM_Client - Custom_753.dat
 outbox/MDM_Client - Custom_757.dat
 outbox/MDM_Client - Custom_758.dat
 outbox/TableExport_198.zip
 outbox/TableExport_199.zip
 PROD_Backup 18-10-26_FULL.zip
 
 Total 568


Last edited by Scrutinizer; 11-20-2018 at 01:23 PM.. Reason: quote tags -> code tags
# 4  
Hi, try:

Code:
awk -F/ '/Client.*log/{print $NF}' "${_TEMP}" | sort -t_ -k 2,2n | tail -1

# 5  
Code:
awk -F'[_./]' 'NF>=2 && $(NF-2)~/^Client/{print $(NF-1)}' myFile | sort -rn | head -1

# 6  
No sort needed to find the maximum.
Code:
awk '$0 ~ SEARCH {
        for(N=1; N<=NF; N++)
        if(($N ~ /^[0-9]+$/) && (MAX < ($N+0)))
        {       MAX=$N; NAME=$0; break; }
}

END {
        N=split(NAME,A,"/");
        print A[N]
}' SEARCH="Client_" FS='[_/.-]' data

# 7  
Quote:
Originally Posted by Corona688
No sort needed to find the maximum.
Code:
awk '$0 ~ SEARCH {
        for(N=1; N<=NF; N++)
        if(($N ~ /^[0-9]+$/) && (MAX < ($N+0)))
        {       MAX=$N; NAME=$0; break; }
}

END {
        N=split(NAME,A,"/");
        print A[N]
}' SEARCH="Client_" FS='[_/.-]' data




Thank you very much everyone! This method works great for me!


However, how would I set the results into the variable called _FDMEE_LOG? I can't seem to get it.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #486
Difficulty: Medium
After a computer program is loaded and setup, the operating system begins executing the instructions at the program's end point in reverse byte-execution mode.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Strange results from 'strings | sort'

Using the 'strings' command and piping the result to 'sort' is producing strange results. I get block of lines that begin with asterisks, then a block that begins with some text, then more lines that begin with asterisks. The actual content is correct - lines beginning with asterisks is the... (5 Replies)
Discussion started by: edstevens
5 Replies

2. Shell Programming and Scripting

Find with rm command gives strange results

I want to remove any files that are older than 2 days from a directory. It deletes those files. Then it comes back with a message it is a directory. What am I doing wrong here? + find /mydir -mtime +2 -exec rm -f '{}' ';' rm: /mydir is a directory (2 Replies)
Discussion started by: jtamminen
2 Replies

3. UNIX for Advanced & Expert Users

Rsync in progress, strange results

Disclaimer, I've been a Linux admin for a while but don't frequently setup rsysnc jobs. Here's the command I'm running on CentOS 5.5, rsync 2.6.8: rsync -arvz --progress --compress-level=9 /src/ /dest/ /src has 1.5 TB of data, /dest/ is a new destination and started out empy. Oh ya, both... (4 Replies)
Discussion started by: DustinT
4 Replies

4. UNIX for Dummies Questions & Answers

sort find results

Hi, I have a problem with a shell script. The script should find all .cpp and .h files and list them. With: for file in `find $src -name '*.h' -o -name '*.cpp' it gives out this: H:\FileList\A\E\F\G\newCppFile.cpp H:\FileList\header01.h H:\FileList\B\nextCppFile.cpp ... (4 Replies)
Discussion started by: shellBeginner75
4 Replies

5. Shell Programming and Scripting

Help with sort folder results

Here is the code, but the list is not sorted properly (alphabetically)? <?php function folderlist(){ $startdir = './'; $ignoredDirectory = '.'; $ignoredDirectory = '..'; if (is_dir($startdir)){ if ($dh = opendir($startdir)){ while (($folder = readdir($dh)) !== false){ if... (0 Replies)
Discussion started by: mrlayance
0 Replies

6. Shell Programming and Scripting

Strange results from FDISK?????

Hi all, I am writing script that returns the size of each disk or partition when called. I am using FDISK -l and parsing the results to get the result I want. When I execute fdisk -l it shows correct results, BUT when I execute the same thing with results to be put in a variable, I get strange... (5 Replies)
Discussion started by: alirezan
5 Replies

7. UNIX for Advanced & Expert Users

Sort command - strange behaviour

Hi guys, I have the following example data: A;00:00:19 B;00:01:02 C;00:00:13 D;00:00:16 E;00:02:27 F;00:00:12 G;00:00:21 H;00:00:19 I;00:00:13 J;00:13:22 I run the following sort against it, yet the output is as follows: sort -t";" +1 -nr example_data.dat A;00:00:19 (16 Replies)
Discussion started by: miwinter
16 Replies

8. UNIX for Dummies Questions & Answers

Strange Results

I am using th following to get the percentage and have never used bc before: percent=$(echo "scale=4;(34117/384000)*100" | bc) 8.884600 percent=$(echo "scale=2;(34117/384000)*100" | bc) 8.00 Why do I get the results of 8.00 instead of 8.88 when using a scale of 2. I only want 2 decimal... (2 Replies)
Discussion started by: mariaa33
2 Replies

9. AIX

Strange ls results..

Multipart question.. Can anybody explain why this happens : -rw-rw-r-- 1 fnsw fnusr 1531061 Feb 13 21:45 filename1.log -rw-rw-r-- 1 fnsw fnusr 1760706 Feb 10 22:10 filename2.log -rw-rw-r-- 1 fnsw fnusr 1525805 Aug 16 2005 filename3.log -rw-rw-r-- 1... (3 Replies)
Discussion started by: dbridle
3 Replies

10. UNIX for Dummies Questions & Answers

How to sort find results

Hi-- Ok. I have now found that: find -x -ls will do what I need as far as finding all files on a particular volume. Now I need to sort the results by the file's modification date/time. Is there a way to do that? Also, I notice that for many files, whereas the man for find says ls is... (8 Replies)
Discussion started by: groundlevel
8 Replies

Featured Tech Videos