find命令:路径
hehe@ubuntu:/home/shell/12$ cat 12-2.sh
#! /bin/bash
#指定多个路径
file=`find /etc /usr/local -name bin`
echo "$file"
测试:
#! /bin/bash
#搜索HTTPd.conf 的文件
file=`find /etc -name httpd.conf -print`
# find /etc -name "data[123abc]" -print == find /etc -name "data[1-3a-c] -print"
#可搜索 data1 data2 data3 dataa datab datac 的文件
#输出前五行
head -5 $file
删除所查找的:
#! /bin/bash
#删除后缀为 .xxx 的文件
find /home -name "*.ppp" -exec rm -f {} \;
#如果命令成功退出 则输出成功提示 否则给出错误提示
if [ $? -eq 0 ]
then
echo "the files have been deleted successfully";
else
echo "failed to delete file";
fi