0

I am on SunOS machine trying to get the date string of the past minute, yesterday I used this command I found on the internet

expr `date +%Y%m%d%k%M` - 1 

which is worked just fine and I saw the output and this is the output I got from my session that is still opened:

bash-3.00$ expr `date +%Y%m%d%k%M` - 1 201303131641 

Now I am trying to run this command on the same session and I got this output:

bash-3.00$ expr `date +%Y%m%d%k%M` - 1 expr: syntax error 

My machine is running this OS:

bash-3.00$ uname -a SunOS mySunOS 5.10 Generic_144488-11 sun4v sparc SUNW,Netra-T2000 

I think there is some environmental variable or something that have been changed, can anyone help me out with this?

1 Answer 1

3

Try %H instead of %k. Yesterday it probably worked because the hour had double digits then. Note that this is not a good way to get the previous minute, because of what happens when the time is exactly on the hour.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.