UNIX Scripting and Retreiving Last Date Modified for Files

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
I would like to write a UNIX script that will list the contents of a directory similarly to how DOS will output a directory. This is for a SAS program that was originally written for a Windows system that needs to work on UNIX.

When you run ls -l or ll in UNIX, it never lists the year. How can I get it to list the year?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
You can use the --time-style option.

Something like --time-style=full-iso

You can run `man ls` to see more information.
 

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
I wish we were using OpenBSD...just for the -T feature of ls. That will force to display the year.

I have made something, I'll probably post my solution once I get it finished up. I'm sure it'll be worth something to someone in the future.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Crusty's suggestion seems to be the best if you already have or can install the GNU version of ls. Its --time-style option can take any format supported by GNU date.