linux - ls -ltr | grep "date | awk '{print $2" "$3}'" not working for single digit day -


this based on link https://unix.stackexchange.com/questions/10041/how-to-get-only-files-created-after-a-date-with-ls/207251#207251

i found below ls -ltr code list files of current date.

ls -ltr | grep "date | awk '{print $2" "$3}'" 

its providing output fine 10th 31st of month. not providing output 1st 9th of month. found there space month , day ie, day single digit not double.

-rw-r--r-- 1 oracle oinstall 11533 jun 31 22:45 c_1025_2015jun02.log.gz  

: above command worked fine.

-rw-r--r-- 1 oracle oinstall 11533 jun  3 22:45 c_1025_2015jun02.log.gz  

: above command didnt work there space before 3 other single space month , day in linux (one decimal missing).

but worked fine when put 1 more single space between $2" "$3 inside shell script. have permanent solution in shell script. there can add along above ls -ltr code space issue.

instead why dont try find command.

find /data -mtime -1 |xargs |ls -l | awk '{print $2" "$3}'" | awk '{ total += $5 }; end { print total/1024/1024/1024 }'


Comments