help me out


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help me out
# 1  
Old 06-01-2010
help me out

Hi,

Code:
var=`date`
str=`echo "${var}" | awk '{ printf substr($0,5,12); }'`
echo ---------------
echo $str
echo ---------------

when i am executing this i am geting result as "Jun 1 06:03"
how ever if u look at the O/P of date mcommand it looks like this
Code:
Tue Jun  1 06:03:28 EDT 2010

Please mark that there are two spaces in between June and 1 on the result of date command.

cud anyone help to keep the O/P from awk, same as that of date command.

For ref I am pasting the output again
Code:
Jun 1 06:03

op from awk
Code:
Jun  1 06:03

op from date command

Moderator's Comments:
Mod Comment Please use CODE tags, ty

Last edited by pludi; 06-01-2010 at 07:57 AM..
# 2  
Old 06-01-2010
try;

Code:
$ date +'%a %b %e %H:%M'
Tue Jun  1 12:45

# 3  
Old 06-01-2010
Code:
[house@leonov] var=$( date ); str=${var:4:12}; echo "$str"
Jun  1 14:32

This User Gave Thanks to dr.house For This Post:
# 4  
Old 06-01-2010
Ah, the OP didn't want week day just observed.

Code:
$ date +'%b %e %H:%M'
Jun  1 14:46

This User Gave Thanks to clx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question