> Want the last version of a file:
>   ls -rt|tail -1
> 
> How do you do that with find?

Yes, I do find 'ls' is nice for just quickly listing a directory in a
chosen order.

To do the same thing in 'find' you'd probably want to couple it with a
sort, eg

find . -type f -printf "%T+/%p\n" | sort | tail -1

The 'find' is more verbose, but the benefit is that you could use it as
part of a pipeline and it works better if there are hierarchical
directories. For example, as the start of further processing (and
dealing with newlines in file names by using 0 terminators):

find . -type f -printf "%T+/%p\0" | sort -z | cut -z -d '/' -f 2- | ...

ie, print ordinary files with timestamp, sort, remove the timetamp, etc

regards, Glenn
-- 
pgp: 833A 67F6 1966 EF5F 7AF1  DFF6 75B7 5621 6D65 6D65
_______________________________________________
luv-main mailing list
[email protected]
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Reply via email to