Question : get latest file in the directory in unix

Hi,
I have multiple files appending with a timestamp in a directory,where i need to get the latest file
including complete directory path.
I tried as:
ls -ltr FileName_*.txt | tail -1 ,but it is not correct.

I am expecting only latest file with the complete path.


Thanks

Answer : get latest file in the directory in unix

Further,

to exclude possible subdirectories use the "-d" option, and to make the ordering and arrangement look the same even without "| tail -1"  use the "-1" option, like

ls -rtd1 /full/path/to/FileName_*.txt | tail -1

Please note that the new "ls" option is the digit "1", not the letter "l" (lowercase L).

wmp
 

Random Solutions  
 
programming4us programming4us