How to list todays and yesterdays .rej files from a directory?

I am trying to display todays and yesterdays .rej files from a directory.

 ls -lrt *.rej | grep 'Aug 12' ; ls -lrt *.rej | grep 'Aug 13'

Which is working as above.
But i want take 'Aug 12' and 'Aug 13' from a variable and the command should work everyday.

I am able to get todays files by using belows pseudo code.
psuedo code:

d=$ `date '+%b %d'` 
yest=$(`date -d '1 day ago' +'%d %d'`)
ls -lrt *.rej | grep 'd' ; ls -lrt *.rej | grep 'yest'

but i am facing problem while printing yesterdays date files.

Error is date: Not a recognized flag: d
Usage: date [-u] [+"Field Descriptors"]

Could anyone help where i am doing wrong?

-d is a GNU extension. how about using find -mtime -2 ?

var_today=$(date "+%b %d")
var_yest=$(date --date="yesterday" "+%b %d")
ls -lrt *.rej | grep "$var_yest" ; ls -lrt *.rej | grep "$var_today"

---------- Post updated at 07:50 AM ---------- Previous update was at 07:47 AM ----------

Thanks for the info.
But i am getting below error message:

$ sh sample.sh
date: Not a recognized flag: -
Usage: date [-u] [+"Field Descriptors"]
ls: 0653-341 The file *.rej does not exist.
ls: 0653-341 The file *.rej does not exist.
$

Check if your bash supports date or not..
enter below commands in bash..

date
date "+%b %d"   
date --date="yesterday" "+%b %d"

uhm... did you miss his first post where his date command did not take any options?

Please try:

find . -name '*.rej' -mtime -2
1 Like
$ date
Mon Aug 13 08:57:39 EDT 2012
$ date "+%b %d"
Aug 13
$ date --date="yesterday" "+%b %d"
date: Not a recognized flag: -
Usage: date [-u] [+"Field Descriptors"]
$

These are the outputs which i am getting.

---------- Post updated at 08:04 AM ---------- Previous update was at 07:59 AM ----------

Thank you so much.. it was working.. Could you briefly explain the command?

try this one..

date -d 'yesterday' "+%b %d"

@pamu: the OP's date command does not support -d flag...this is very much evident from his posts.

if above all suggestions are not working try this..

for i in $(find -mtime -1 | awk -F "./" '{ print $2}')
do
ls -lrt $i
done