Grep date from ls -l

I have a script which required the month and day as the input

ex : ./script <Month> <date>

from this I get the list of files to do further logics. The problem is when I assign these $1 and $2 to variables, and use grep command in the script

ls -l |grep "$1 $2"

it works fine for two digit dates, but for single digit dates, it doesnt work as Unix leaves an additional space in the ls -l list..

How can get this done.

  • will match any number of the preceding character. Also it's good to match a space after the last value so that you don't find Apr 22 when you are actually searching for Apr 2, for example.
ls -l |grep " $1  *$2 "