1752756 Members
4826 Online
108789 Solutions
New Discussion

Re: date format..

 
SOLVED
Go to solution
friend_1
Occasional Advisor

date format..

Hi,
how to retrieve date format like this(Tue Apr 7)

Thanks,
11 REPLIES 11
Suraj K Sankari
Honored Contributor

Re: date format..

Hi,

See the output

[suraj@rspc521 root]# date +%a" "%b" "%d
Tue Apr 07

where
%d day of month (01..31)
%a localeâs abbreviated weekday name (Sun..Sat)
%b localeâs abbreviated month name (Jan..Dec)
for more information see the man page of date

Suraj
Taifur
Respected Contributor

Re: date format..

Hi Friend,

For date format, you can check below link


http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51_HTML/MAN/MAN1/0083____.HTM


Rgds//
Taifur
Steven Schweda
Honored Contributor

Re: date format..

> For date format, you can check below link

Why would an HP-UX user wish to use a Tru64
"man" page for info like this? (And if he
_did_ want a Tru64 "man" page, why would he
want an old, obsolete one rather than the
latest one?)
Ganesan R
Honored Contributor

Re: date format..

Hi Friend,

#date +%a" "%b" "%e
Tue Apr 7
Best wishes,

Ganesh.
Dennis Handly
Acclaimed Contributor

Re: date format..

>Taifur: For date format, you can check below link

That was a Tru64 man page, accept no substitutes:
http://docs.hp.com/en/B2355-60130/date.1.html
Frank de Vries
Respected Contributor

Re: date format..

To stick it in a variable do

VAR=$(date +%a" "%b" "%e)
print $VAR
Tue Apr 7

Cheerio friend
Look before you leap
friend_1
Occasional Advisor

Re: date format..

hi,

sdate=`date +%a" "%b" "%e`

awk '/'$sdate'/ {x++} /ORA-/ && x' alert.txt
syntax error The source line is 1.
The error context is
>>> /Wed <<<
awk: Quitting
The source line is 1.

thanks,
Patrick Wallek
Honored Contributor

Re: date format..

So, what are you trying to accomplish with the awk statement? What results do you expect?
Dennis Handly
Acclaimed Contributor
Solution

Re: date format..

>awk '/'$sdate'/ {x++} /ORA-/ && x' alert.txt

If you want to find lines with the date then start printing lines with "ORA-", you could do:
awk -vvar="$sdate" '$0 ~ var {x++} /ORA-/ && x'

You can't stutter quotes if $sdata has white space. You must quote $sdata if you want to echo it, since it has multiple spaces.
Since you are using a variable and not a constant RE, you must use the ~ operator.