Shell 判断文件类型

rechanel 2011-05-11

#!/bin/sh                                                                                                                                                            

source_dir="./down-5"

target_dir="./document"

if[-d$target_dir];then

echo"$target_dirisexist"

else

`mkdir"$target_dir"`

echo"mkdir$target_dirdone."

fi

foriin$source_dir/*;do

case"$i"in

*.pdf)

echo"thenPDFnameis$i"

`cp$i$target_dir`;;

*.doc)

echo"thendocis$i"

`cp$i$target_dir`;;

*.docx)

echo"thendocxis$i"

`cp$i$target_dir`;;

esac

done

相关推荐