stupid bash question
I am pretty new to *nix and I have a possibly stupid question. I have a need to capture, as a variable, the month and date as it is displayed when you issue a date command.
bash prompt$ date
bash prompt$ Thu Sep 9 23:14:21 2004
(emphasis mine - since the date is < 10, there are 2 white spaces between Sep and 9)
When I issue a cut command after date (date | cut -c5-10), I get the exact 6-digit string (Sep 9) result that I am seeking. HOWEVER, when I try to capture that result into a variable, things do not come out the same. It seems that the process of storing the result of the date | cut command in a variable strips off one of the spaces.
bash prompt$ JJ=$(date | cut -c5-10)
bash prompt$ JJ=`date | cut -c5-10`
bash prompt$ echo $JJ
bash prompt$ Sep 9
(There now only one white space between Sep and 9. Where did the other white space go?)
What is it that I am doing wrong? Your help would be appreciated.
Last edited by tisleti; 09-09-2004 at 10:34 PM.