当前位置: 技术问答>linux和unix
大虾们好,小弟问几个关于BASH编程的问题,请赐教!!
来源: 互联网 发布时间:2015-07-14
本文导语: 1。oldstr="i am" newstr=$oldstr+"mark" #上面这句怎么写才能把两个字符串连接起来 2。怎么判断用户输入了几个命令参数?? THANKS | #!/bin/bash myfind() { for file in $1/*; do [ "`...
1。oldstr="i am"
newstr=$oldstr+"mark"
#上面这句怎么写才能把两个字符串连接起来
2。怎么判断用户输入了几个命令参数??
THANKS
newstr=$oldstr+"mark"
#上面这句怎么写才能把两个字符串连接起来
2。怎么判断用户输入了几个命令参数??
THANKS
|
#!/bin/bash
myfind() {
for file in $1/*; do
[ "`basename $file`" = "$target" ] && echo "$file"
[ -d $file ] && myfind $file
done
}
if [ $# -ne 2 ]; then
echo "Usage: $0 path file"
exit 1
fi
if [ ! -d $1 ]; then
echo "$1 is not a directory"
exit 1
fi
target=$2
myfind $1
myfind() {
for file in $1/*; do
[ "`basename $file`" = "$target" ] && echo "$file"
[ -d $file ] && myfind $file
done
}
if [ $# -ne 2 ]; then
echo "Usage: $0 path file"
exit 1
fi
if [ ! -d $1 ]; then
echo "$1 is not a directory"
exit 1
fi
target=$2
myfind $1