分页: 1 / 1
shell脚本的问题
发表于 : 2008-05-22 9:35
由 NextBlue
#!/bin/bash
: #This is my an exp programme
: echo "Please input the file name: \C -n"
: read name
: touch $name
: echo "$name :"
: for ((i=1;i<30;i++))
: do
: read line[$i]
: if line[$i]=“:end”
: then
: break
: fi
: cat>$name
: done
: echo "Bye!"
: 为啥一输入就break了???
发表于 : 2008-05-22 9:56
由 eexpress
cat>$name
什么意思啊。
发表于 : 2008-05-22 10:10
由 xiooli
if line[$i]=“:end” 换成 if [ ${line[$i]} == ":end" ]
还有那个cat>$name换成name=“”试试。
发表于 : 2008-05-22 12:48
由 NextBlue
eexpress 写了:cat>$name
什么意思啊。
是想将read的内容写入到$name这个文件里面
发表于 : 2008-05-22 12:51
由 NextBlue
xiooli 写了:if line[$i]=“:end” 换成 if [ ${line[$i]} == ":end" ]
还有那个cat>$name换成name=“”试试。
改了可还是不行啊。。。。
发表于 : 2008-05-22 13:08
由 BigSnake.NET
代码: 全选
#!/bin/bash
#This is my an exp programme
echo -n "Please input the file name: "
read name
echo "$name :"
echo -n > "$name"
read line
while [ "$line" != ':end' ]
do
echo "$line" >> "$name"
read line
done
echo "Bye!"
发表于 : 2008-05-22 13:17
由 NextBlue
BigSnake.NET 写了:代码: 全选
#!/bin/bash
#This is my an exp programme
echo -n "Please input the file name: "
read name
echo "$name :"
echo -n > "$name"
read line
while [ "$line" != ':end' ]
do
echo "$line" >> "$name"
read line
done
echo "Bye!"
那我原先写的那个哪有问题啊?echo -n > "$name"和echo "$line" >> "$name"是什么意思呢?