What shell command might I use to open the last alphanumeric file in a directory? -


i have log files auto generated , organized in directory such:

  • logs/laravel-2015-07-01.log
  • logs/laravel-2015-07-02.log
  • logs/laravel-2015-07-03.log
  • logs/laravel-2015-07-04.log
  • logs/laravel-2015-07-05.log

i want create shell alias prints out tail of latest log file (laravel-2015-07-05.log @ moment).

alias plog="tail ___________________________" 

what can fill in blank select latest log file?

a new log file generated each day , date string pattern should apparent. server timezone files generated not same local timezone, solution i'm looking find log file latest date (not today's date).

assuming these files in directory , follow strict naming format

laravel-yyyy-mm-dd 

then can run ( in log directory )

view last log tail

ls | tail -n 1 | xargs tail 

this uses default alphabetical sort order of ls

can adjust if outside directory run :

ls -d logs/* | tail -n 1 | xargs tail 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -