0

I am beginner to Shell Script.
Just want to know how to fetch date of the file from the properties in the UNIX Shell Script?
When I put 'ls -lrt' , could fetch the date where as for last six months we could see only date and time but year is not populated.

Output:

Jan 10 2022
Feb 20 2022
Jan 11 15:10

For third one, year is not populated.

I tried the following commands '''--full-time''', '''--time-style''' and '''stat''' but its not supporting in my UNIX version
Thanks in advance

karthickraja
  • 214
  • 1
  • 7
  • 1
    There's no standard command for that; you need to specify the target OS. – Fravadona Mar 26 '23 at 21:10
  • Best to be sure `stat` isn't already on your machine. you could do `find / -name 'stat' -ls` but it may take a long time to complete. If you can't find it then, 2nd best is to search for an installable version of `stat` for your OS. 3rd case would be to find the source code and compile it. Good luck. – shellter Mar 27 '23 at 04:13
  • Other than stat , is there any other solution – karthickraja Mar 27 '23 at 06:12
  • the most portable way to get the modification timestamp would be `perl -le 'for (@ARGV) {print ((stat($_))[9])}' file1 file2 ...` – Fravadona Mar 27 '23 at 07:44

0 Answers0