日期:2014-05-16  浏览次数:20658 次

请问一下,这个简单的shell脚本究竟那里有问题?
我想把某一个日期的文件全部列出来,在网上找到一个很流行的脚本,但是我运行的时候总是无法得到正确的值。
没有反应。

 #!/bin/sh
# The right of usage, distribution and modification is here by granted by the author.
# The author deny any responsibilities and liabilities related to the code.
#
OK=0
A=`find $1 -print`
if expr $3 == 1 >/dev/null ; then M=Jan ; OK=1 ; fi
if expr $3 == 2 >/dev/null ; then M=Feb ; OK=1 ; fi
if expr $3 == 3 >/dev/null ; then M=Mar ; OK=1 ; fi
if expr $3 == 4 >/dev/null ; then M=Apr ; OK=1 ; fi
if expr $3 == 5 >/dev/null ; then M=May ; OK=1 ; fi
if expr $3 == 6 >/dev/null ; then M=Jun ; OK=1 ; fi
if expr $3 == 7 >/dev/null ; then M=Jul ; OK=1 ; fi
if expr $3 == 8 >/dev/null ; then M=Aug ; OK=1 ; fi
if expr $3 == 9 >/dev/null ; then M=Sep ; OK=1 ; fi
if expr $3 == 10 >/dev/null ; then M=Oct ; OK=1 ; fi
if expr $3 == 11 >/dev/null ; then M=Nov ; OK=1 ; fi
if expr $3 == 12 >/dev/null ; then M=Dec ; OK=1 ; fi
if expr $3 == 1 >/dev/null ; then M=Jan ; OK=1 ; fi
if expr $OK == 1 > /dev/null ; then
ls -l --full-time $A 2>/dev/null | grep "$M $4" | grep $2 ;
else
echo Usage: $0 path Year Month Day;
echo Example: $0 ~ 1998 6 30;
fi


我先在当前目录下,创建了几个文件,运行的时候:
 find.sh  ./  2012 10 8

怎么着,也要显示今天10月8号创建的文件啊。可是就是没反应。。。

各位大侠帮忙分析下啊
------解决方案--------------------
#!/bin/sh
# The right of usage, distribution and modification is here by granted by the author.
# The author deny any responsibilities and liabilities related to the code.
#
OK=0
A=`find $1 -print`
if expr $3 == 1 >/dev/null ; then M=Jan ; OK=1 ; fi
if expr $3 == 2 >/dev/null ; then M=Feb ; OK=1 ; fi
if expr $3 == 3 >/dev/null ; then M=Mar ; OK=1 ; fi
if expr $3 == 4 >/dev/null ; then M=Apr ; OK=1 ; fi
if expr $3 == 5 >/dev/null ; then M=May ; OK=1 ; fi
if expr $3 == 6 >/dev/null ; then M=Jun ; OK=1 ; fi
if expr $3 == 7 >/dev/null ; then M=Jul ; OK=1 ; fi
if expr $3 == 8 >/dev/null ; then M=Aug ; OK=1 ;