![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep latest file based on date. | lweegp | Shell Programming and Scripting | 12 | 04-03-2009 03:10 AM |
| Reading a file using sh with spaces in filename | jekl5 | Shell Programming and Scripting | 4 | 02-29-2008 10:18 AM |
| Loop through files in dir, omit file with latest date | stringzz | Shell Programming and Scripting | 2 | 12-04-2007 02:04 PM |
| Grabing Date from filename and adding to the end of each line in the file. | rkumar28 | Shell Programming and Scripting | 1 | 05-01-2007 08:25 PM |
| Copying files with the latest date | shashi_kiran_v | UNIX for Dummies Questions & Answers | 34 | 08-02-2005 12:07 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
get the latest file by reading the date in the filename.
Hi,
I grep for a pattern in a list of files. "grep -i -l $pattern *.datx*" it may give me n number of files. say for eg, it gives me 2 files. lock_eicu_20071228_00000000.dat_20071228_05343100 lock_eicu_20080501_00000000.dat_20080501_05343900 out of these 2 files I need to get the latest file according to the date present after the .dat extn. As 20071228 is older than 20080501, i need to get the second file. so in the above eg, i need to get the filename lock_eicu_20080501_00000000.dat_20080501_05343900 can u please help. |
|
||||
|
Hi frank, one more help please,
I do below to list my files in chronological order. ls -ltr *.datx* | tr -s ' ' | cut -d' ' -f9 it gives me list of files like below. lock_eicu_20081120_00000000.datx_20081120_05315400 lock_eicu_20081118_00000000.datx_20081118_06303100 lock_eicu_20081111_00000001.datx_20081111_15531300 lock_eicu_20081111_00000000.datx_20081111_06335300 lock_eicu_20081030_00000000.datx_20081030_05342900 lock_eicu_20081016_00001111.datx_20081016_15525600 lock_eicu_20081016_00000000.datx_20081016_06350500 lock_eicu_20081001_00000000.datx_20081001_05344100 lock_eicu_20080912_00000000.datx_20080912_05305200 lock_eicu_20080904_00000000.datx_20080904_05335500 lock_eicu_20080822_00000000.datx_20080822_05344200 lock_eicu_20080812_00000000.datx_20080812_06331200 lock_eicu_20080808_00000000.datx_20080808_05345200 lock_eicu_20080806_00000000.datx_20080806_06343800 lock_eicu_20080802_00000000.datx_20080804_05332000 lock_eicu_20080718_00000000.datx_20080718_06533100 lock_eicu_20080606_00000000.datx_20080606_05340600 lock_eicu_20080603_00000000.datx_20080603_06345300 lock_eicu_20080531_00000000.datx_20080602_05304300 lock_eicu_20080529_00000000.datx_20080529_06330500 lock_eicu_20080501_00000000.datx_20080501_05343900 lock_eicu_20080429_00000000.datx_20080429_06311200 lock_eicu_20071228_00000000.datx_20071228_05343100 how do i sort the files again chronologically as per the date found just after .datx? i mean in the list if u see "lock_eicu_20071228_00000000.datx_20071228_05343100" is the oldest file as it has date 20071228 after datx. so i need to list this file first and then sort so on. Please help. Thanks again |
|
||||
|
hey Franklin,
care to explain the breakdown of the awk statement? thanks |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|