0

I have a file in linux:

-rw-r--r-- 1 quangt alphaa0   8170473 Apr 23 23:06 us_pd_syn_map.log

I want to get the date of the file : "Apr 23"

How do I get it?

fpnick
  • 616

1 Answers1

1
  1. Use either file mtime or file stat to get the modification time in "Unix timestamp" format:

    set timeunix [file mtime "us_pd_syn_map.log"]
    
  2. Format it using clock format:

    set timestr [clock format $timeunix -format "%b %d"]
    

    If you want different formats depending on how old the file is, compare the timestamp against clock seconds which returns the current timestamp.

grawity
  • 501,077