1

I need convert the date appears from "ls -la" command from a file, in seconds in SOLARIS OS I can't use "date -d" or similar like a Linux SO

4 Dec 9 14:30

Kind Regards, Arturo

  • 1
    Welcome to Stack Overflow. We’d love to help you. To improve your chances of getting an answer, here are some tips: [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – Paul Roub Dec 09 '15 at 14:36
  • Which version of Solaris? What's in `/usr/sfw/bin` or `/usr/gnu/bin`? – Andrew Henle Dec 09 '15 at 17:17

1 Answers1

2

Arturo, I second Andrew's comment -- what version of Solaris? -- but I suggest you run /bin/uname -a or cat /etc/release to report it.

You wrote "convert the date appears from "ls -la" command from a file, in seconds", so I'm assuming you want to print out the time in seconds since the epoch, instead of a more human-readable date.

If you're running a version of Solaris 11, and you have /usr/gnu/bin, you can have /usr/gnu/bin/ls print out the seconds since the epoch:

/usr/gnu/bin/ls -l --time-style="+%s"

See here for details.

I don't have ready access to a Solaris 10 system, but you might be able to use the output of /bin/ls -le (giving resolution in seconds) and process it modifying the awk script in this answer:

Community
  • 1
  • 1
tpgould
  • 36
  • 1