您的位置:首页 > 运维架构 > Shell

[30期] 我的第一个shell脚本~感谢其他几位同学帮助

2011-07-27 09:06 295 查看
折腾一晚上了,第一脚本终于写出来了

中途遇见点错误

syntax error near unexpected token `do'

这个错误 就是因为我再windows下编写的 稍微的解决了下

可是问题还是出现,在高纪胜和叶学辉的帮助下 还是改正了 哈

我说下功能 这个主要写的是find 几个选项 通过文件大小 文件名 文件所有者 来搜索

希望各位同学能帮我再简化下脚本 3Q3Q了~

#!/bin/bash
#!this shell about user to search file!the search mode about filesize,filename,fileowner
#!author:lamp30Q qindongsheng qq:229932704
echo "my first shell,if the shellfile has errors,hope everybody to change"
echo
echo
select mode in size name userfile
do
break
done
echo "pls input you want to search the DIR,"
read sdir
case $mode in
size)

echo "pls input the file Least size,For Exmple:100MB,you must input +204800"
read fileleast
echo "pls input the file Max size,For Exmple:100MB,you must input -204800"
read filemax
/usr/bin/find $sdir -size $fileleast -a -size $filemax
;;
name)

echo "pls input the filename as you want to search "
read filename
/usr/bin/find $sdir -name $filename
;;
userfile)

echo "pls input username as you wang to search file owner"
read username
/usr/bin/find $sdir -user $username
;;
*)
echo "input error"
esac

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: