Date Format - preserve whitespace

I am trying to change the date format for the following:

 
YESTER=`TZ=aaa24 date +%b" "%d | sed 's/0/ /'`
 
 
TraceList=$(ls -ltR /pdt/logs | grep "$YESTER" | awk '{print $9}')
 
CMD2=$(find /disk/dan/dansFiles/pass/logs/$TList -name cmd\* -prune)

what I am trying to do in the above script is look for all files created yesterday...however when I do an ls -ltR the files have a date in this format:

 
"Jul  5"
 

with two spaces as opposed to

 
 
"Jul 5".
 

How can I get the yesterday variable to preserve the whitespace?

If you just need teh file names, you can remove supress the spaces from teh output of ls -lrt itself

$ ll
total 0
-rw-r--r--   1 oper   users            0 Jul  6 17:44 345
-rw-r--r--   1 oper   users            0 Jul  6 17:51 a
-rw-r--r--   1 oper   users            0 Jul  6 17:52 b
-rw-r--r--   1 oper   users            0 Jul  6 17:52 c
$ var1=`TZ=aaa date +%b" "%d | sed 's/0//'`
$ echo $var1
Jul 6
$ file_list=$(ll | tr -s ' ' | grep "$var1"  | awk '{print $9}')
$ echo $file_list
345 a b c
$
1 Like