分页: 1 / 1

字符串比较的问题

发表于 : 2010-01-02 14:51
yangstone
我想写个脚本将某个文件夹下面出现的pdf文件全部移动到某个地点,、

for filename in $tempfile
do
if test -e .*pdf
then
mv filename ./doc/

tempfile 保存有当前文件夹下的文件列表,但是test哪一行有问题,字符串比较不对呀,望各位指教

Re: 字符串比较的问题

发表于 : 2010-01-02 15:16
xiooli

代码: 全选

find your_dir -name "*pdf" -exec mv {} another_dir \;
ps: 此命令系在 win 下敲滴,未经验证,请先验证无误后再使用,如出现任何问题,本人概不负责,特此声明!

Re: 字符串比较的问题

发表于 : 2010-01-02 15:30
yangstone
明白你的意思,我还是想搞清楚为什么我写的那个字符串比较不对呢?

ps:因为下载的东西都在一个文件夹下,所以很乱,想写个脚本,用cron来做的,将文件归类以下,没写过脚本,望指教了

Re: 字符串比较的问题

发表于 : 2010-01-02 15:42
yangstone
改成了:
for filename in $tempfile
do
if [ $filename == "*.pdf" ]
then
mv $filename ./doc
还是不对呀!

Re: 字符串比较的问题

发表于 : 2010-01-02 15:59
yangstone
改成 if [[ $filename == *pdf ]]对了,。。。。。。。。。。。。。。。。 :em06 :em06 :em06