Skip to content
Advertisement

space issue between Month and date in linux

In my linux system date is having two space between month and date(ex:Jun 4) .so i used date command(ex:date +’%b %_d %H’) and stored the value in variable that time i am getting only one space between month and date(ex:Jun 4), so please help me to get the actual system format while using variable.

Advertisement

Answer

date is outputting the string you want; I suspect you aren’t properly quoting the variable value when you expand it.

$ d=$(date +'%b %_d %H')
$ echo $d
Jun 6 20
$ echo "$d"
Jun  6 20
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement