Find files and sort by timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files and sort by timestamp
# 1  
Old 07-14-2017
Find files and sort by timestamp

Used below command to get list of files sorted by timestamp
Code:
 
 find -L . -type f -name '*dat*'  | xargs ls -ltrg

I want to get only the filenames so I tried adding basename but it doenst work , can some one advise on how to get only file name
# 2  
Old 07-14-2017
Try:
Code:
find -L . -type f -name '*dat*' -exec ls -tr {} + | sed 's|.*/||'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error when connecting to remote server to find files with timestamp today's day

I am connecting to remote server and try to check if files with timestamp as Today's day are on the directory. Below is my code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly; Today=`date +%Y%m%d`; if ;then echo "We... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

How to sort grep result based on timestamp?

Hi, Trying to sort grep result based on timestamp of the filename. I have the following result and want to sort them on timestampgrep -i 'ERROR' *log*2013* s_m_xxx_xxx_xxx_xxx_xxxx.log.20130906092431:TRANSF_1_1_1> DBG_21216 Finished transformations for Source Qualifier . Total errors ... (5 Replies)
Discussion started by: bobbygsk
5 Replies

3. Programming

Sort the files on their name and then the timestamp using Perl

Hi All, I am new to Perl. I have a scenario to code. In a folder I have number of files and they will start with P01 or P02 or P03 and so on..I have to sort them on name first and then on time stamp. Ex. File name timestamp P01_file1.txt 1PM P02_file1.txt 1AM P01_file2.txt 2PM... (12 Replies)
Discussion started by: unankix
12 Replies

4. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

5. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

6. UNIX for Dummies Questions & Answers

sort and find duplicates for files with no white space

example data 5666700842511TAfmoham03151008075205999900000001000001000++ 5666700843130MAfmoham03151008142606056667008390315100005001 6666666663130MAfmoham03151008142606056667008390315100005001 I'd like to sort on position 10-14 where the characters are eq "130MA". Then based on positions... (0 Replies)
Discussion started by: mmarshall
0 Replies

7. UNIX for Dummies Questions & Answers

Shell script which will sort all the files in a directory with the timestamp they were created

Team, Pls help writing a shell script which will sort all the files in a directory with the timestamp they were created. (like ls -lrt) (6 Replies)
Discussion started by: asappidi
6 Replies

8. Shell Programming and Scripting

sort for timestamp information-YYYY-MM-DD HH:MM:SS

Dear all, Please advice how do I sort a file based on timestamp information. I want to sort the second column in asc/desc order which has timestamp information in format YYYY-MM-DD HH:MM:SS Example File - Input.txt contains cat ss.txt 100|2009-03-30 11:38:43 141|2009-06-01 12:12:01... (1 Reply)
Discussion started by: sureshg_sampat
1 Replies

9. Shell Programming and Scripting

Find files older then today & display with timestamp info

Small query- I want to do some operation on all the files older then today. Before I do that operation, i want to verify if the command works properly or not. Surprisingly, the command below returns me file, which are created today - find /mrk_archive/PG/ftp/incomming/gbs/2008 -type f... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

10. UNIX for Dummies Questions & Answers

sort file on timestamp and a alphabetic code in it

Hi, I have files like ER08EVENTDC080911232324.txt ER08EVENTCD080911232323.txt ER08EVENTCD080910222222.txt ER08EVENTCD080910130245.txt ER08EVENTAA080910130245.txt ER08EVENTAA080910232000.txt ER08EVENTAA080911015005.txt ER08EVENTAA080910130150.txt ER08EVENTAA080910232010.txt... (5 Replies)
Discussion started by: harshada
5 Replies
Login or Register to Ask a Question