How to grep a particular pattern using a variable

Hi all,

I am searching for the files with a pattern which is stored in a variable.
eg:
the day is taken from the date format into a variable "day"
I am trying to search with the pattern in that variable.

ls -ltr | grep "$day"

I am not getting the filtered output.

Please help me in how to search for the pattern which is in a variable.

Thanks,

this should work.

try echoing the contents of day

echo $day

that should give an idea on whats going wrong

am doing an echo
but how to use that in a grep
ls -ltr | grep "$day" is not working

if possible show us the contents of ls -ltr

and echo $day

i cant give u the output as its very huge
its giving all the files with the other days also..
echo $day :
output : 02

I have made a little change and am getting the output but if the date is Sep 2 then if am searching for that using the variable then am getting the output as all the files which contain sep 2
eg :
Sep 23
Sep 24 etc.,

I didn't mean to dump the actual source file as such

I was expecting something like,

sample input
&
sample output

hi ...
sample input:
path ="/dir/sample" :we have the files as
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month date filename

desired output for command
cd $path
ls -ltr | grep "$day" >samplefile -----(where $day=month1 date1)
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month1 date1 filename

Thanks,

hi ...
sample input:
path ="/dir/sample" :we have the files as
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month date filename

desired output for command
cd $path
ls -ltr | grep "$day" >samplefile -----(where $day=month1 date1)
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month1 date1 filename

Thanks,