My question is how to run a command like date with its parameter into awk or grep commnad? I need to collect a strings contain todays date in the following format.
For example 17/Feb/2003.
man awk :
strftime([format [, timestamp]])
Formats timestamp according to the specification in format. The timestamp should be of the same form as returned by systime(). If timestamp is missing, the current time of day is used.......
so:
awk 'BEGIN{date=strftime("%d/%b/%Y"print date}'
Now see I would put this in a small script,
Here is an example for using grep
M=`date +%b` # Set month three letter
m=`date +%m` # Set month two digits
d=`date +%d` # set Day two digits
H=`date +%H` # Set Hour two digit
Y=`date +%Y` # Set Year four digit
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.