shell 查询当前的文件夹下是否存在某个文件
时间:2014-11-27 15:28 来源:linux.it.net.cn 作者:IT
1.shell文件 find.sh
#!/bin/bash
file_name=$1
echo "$file_name"
ls -l|grep "$file_name"
r=$?
if [ $r == 1 ]; then
echo "不存在此文件"
#exit 1
elif [ $r == 0 ]; then
echo "存在此文件"
#exit 0
fi
2.执行查找
./find.sh test.sh
(责任编辑:IT)
1.shell文件 find.sh
#!/bin/bash
ls -l|grep "$file_name"
if [ $r == 1 ]; then
2.执行查找 ./find.sh test.sh (责任编辑:IT) |