I want to list all files created in a day but it doesn't work
$ day=\'`date "+%b %d"`\'
$ echo $day
>>> 'Mar 12'
$ ll |grep $day
>>> can't open 12'
????? please help me
I want to list all files created in a day but it doesn't work
$ day=\'`date "+%b %d"`\'
$ echo $day
>>> 'Mar 12'
$ ll |grep $day
>>> can't open 12'
????? please help me
Use double quotes, the shell is interpreting your variable as a two part string.
ll | grep "$day"
Instead of adding a single quote on the day variable, try double quoting the day variable with the grep command.
$ day=`date "+%b %d"`
$ echo $day
Mar 12
$ ls -l |grep "$day"
dynix/ptx 4.4.8
Or...
day=`date +%e |tr -d ' '`
mon=`date +%b`
ls -l |nawk '$6 ~ /'$month'/ && $7 == '$day' {print $0}'
This can be scripted, and the day and mon values can also be defined in one's .profile.