shell判定文件夹下存在某种类型的文件

来源:互联网 发布:windows 2012 dhcp 编辑:程序博客网 时间:2024/04/29 04:46

该例程用途:
判定/mnt文件夹下是否存在ko文件。存在则把ko文件mv到update文件夹下,不存在则从update文件夹中把ko文件mv过来

#!/bin/shexist_file(){    if [ -e "$1" ]    then        return 1    else        return 2    fi}exist_file *.kovalue=$?if [ $value -eq 1 ]then  mv /mnt/*.ko /mnt/updateelif [ $value -eq 2 ]then  mv /mnt/update/*.ko /mntfi
0 0