#!/bin/sh for i in {1..5} do echo "Welcome" done@H_502_3@会工作,显示欢迎5次.
#!/bin/sh howmany=`grep -c $1 /root/file` for i in {1..$howmany} do echo "Welcome" done@H_502_3@不行! howmany将等于5,因为grep -c的输出将显示. $1是运行脚本时具体的参数1. @H_502_3@有任何想法吗?
创建一个序列来控制你的循环
原文链接:/bash/386495.htmlfor i in $(seq 1 $howmany); do echo "Welcome"; done