Arthur Hills
Arthur Hills

Reputation: 37

Convert specific date in seconds

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

Upvotes: 1

Views: 153

Answers (1)

tpgould
tpgould

Reputation: 36

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:

Upvotes: 2

Related Questions