Operating System - HP-UX
1830165 Members
2388 Online
109999 Solutions
New Discussion

Need a space in date format

 
SOLVED
Go to solution
Tom Weber_4
Advisor

Need a space in date format

Small issue here with a date format. When I do this at the command line I get desired output:

date "+%b %e"
Jan 7

When I do this:
current=`date "+%b %e"`
echo $current
Jan 7

I lose the extra blank space that I want. What am I missing here?

Thanks in advance! Tom
4 REPLIES 4
Tom Weber_4
Advisor

Re: Need a space in date format

That should show "Jan 7" with two spaces on that first output. I don't think the format came out properly on my initial post.

Tom
Chris Watkins_1
Respected Contributor
Solution

Re: Need a space in date format

echo "${current}"

or

echo "$current"



Will maintain the spacing.

Not without 2 backups and an Ignite image!
Dave Johnson_1
Super Advisor

Re: Need a space in date format

The man page for echo states:
"echo writes its arguments separated by blanks..."

It is treating your string as a list of arguments. You will need to quote the environment variable like this:

current=`date "+%b %d"`
echo "$current"
Jan 7

Later
-Dave
Tom Weber_4
Advisor

Re: Need a space in date format

Got it Chris! Knew it was something simple I was missing. Thanks!