0

I'm looking for a Date for like Mar 1 (i.e. space+padded space of day of month)

This is giving correct format => Mar 1

date -d "yesterday 13:00" +"%b %e"

However, when I try to put into a variable, the extra added space is missing.

DATE=`date -d "yesterday 13:00" +"%b %e"`
echo $DATE gives=> Mar 1 (only padded space getting)

Any idea how to get that => Mar 1 (i.e. space+padded space of day of month)

Shubham
  • 763
  • 5
  • 20

1 Answers1

0

For lots of details, see When to wrap quotes around a shell variable? or I just assigned a variable, but echo $variable shows something else

Basically, you need to quote your variable when you use it:

echo "$DATE"
jhnc
  • 11,310
  • 1
  • 9
  • 26