Sir,
I using the following commands in a file (part of a bigger script):
#!/bin/bash
cd /opt/oracle/bin
ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out
If I run this from the command prompt the result is:
2007-05-16
if I run it as a cron job then I get:
May
In both cases I need to get:
2007-05-16
Can any help with this?
Thanks in advance.
Which OS you are using. I tried the same command in AIX
ls -lt | tail -1 | awk '{print $6}'
and I got 'Jul' as response
We are using suse enterprize 9
Linux 2.6.5-7.283-smp #1 SMP Wed Nov 29 16:55:53 UTC 2006 x86_64 x86_64 x86_64 GNU/Linu
I am not sure..
try executing the command with full path
/bin/ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out
/bin/ls -lt --time-style=locale | ...
Cheers,
ZB
Thanks for all the suggestions and a solution.
time-style= long-iso or time-style=+%Y-%m-%d will do us nicely.
Once again thanks.