|
发表于 2003-9-21 20:57:29
|
显示全部楼层
不客气 ;)得到你的启发,我写了一个查找文件的脚本,你试试看,有什么意见?- #!/bin/ksh
- #name:sfile
- #writer:javalee
- #date:2003/09/21
- #serach some file in your PATH.
- #begin
- (($#!=0))&&echo "Usage:$(basename $0)[Enter]"&&exit 1
- read input?"input last some letter of a command:"
- for i in $(echo $PATH|tr ':' '\n')
- do
- find $i -name "*$input" 2>/dev/null
- done>list
- str=$(ls -l list|awk '{print $5}')
- if [[ $str == 0 ]]
- then
- echo "No Fount"$input"!"
- exit 1
- fi
- nl list
- read doit?"Input Number of command:"
- var=$(cat list|sed -n ${doit}p|cut -f2 -d" ")
- echo "|(R)un?|(F)ileType?|(D)isplay?(scrptfile/txtfile)|(M)an?(binfile)|"
- echo "EnterKey to exit"
- echo -n "Enter your choice:"
- read choice
- case $choice in
- r) exec $var;;
- f) file $var;;
- d) cat $var;;
- m) man $(basename $var);;
- *) exit;;
- esac
- rm list
- #end
复制代码 |
|