Skip to content

Sorting files based on time in Linux

I want to get a list of pathnames of files, divided by one blank space, and the files are sorted based on creation time. I use

find $dir -type f -printf '%T+t%pn' | sort -n 

to sort them, but the problem is, how can to delete all the time before the pathnames?

If I use

find $dir -printf '%p'

I can get a list of pathnames, but I don’t know how to sort them.



You could use cut

find $dir -type f -printf '%T+t%pn' | sort -n | cut -f2
User contributions licensed under: CC BY-SA
5 People found this is helpful