为了账号安全,请及时绑定邮箱和手机立即绑定

将num 设为2 ,并在/root/mydir下建2个文件,为什么该函数并不会结束?

将num 设为2 ,并在/root/mydir下建2个文件,为什么该函数并不会结束?

喵喵时光机 2022-07-21 15:15:28
#!/bin/bashread -p "num=" numfileNum(){while truedoarray1=(`ls /root/mydir`)factnum=${#array1[@]}echo $factnumif [ $num -eq $factnum ];thenbreakfidone}fileNum &在一个shell中后台运行函数fileNum,当/root/mydir目录下文件的数量达到预先设定的$num时,退出函数。问题:例如,将num 设为2 ,并在/root/mydir下建2个文件,但是该函数并不会结束,为什么呢?谢谢!
查看完整描述

1 回答

?
紫衣仙女

TA贡献1839条经验 获得超15个赞

比面shell脚本文件:#===========test.sh! /bin/shecho_line(){ echo date echo "Wellcome to shell func!"}echo_hello(){ echo "Hello World!"}#======================shell调用两函数啊我用【./test.sh echo_hello】却没输我已经给test.sh加执行权限
请问envsetup.sh边
function gettop()
{
local TOPFILE=build/core/envsetup.mk
if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
echo $TOP
else
if [ -f $TOPFILE ] ; then
# The following circumlocution (repeated below as well) ensures
# that we record the true directory name and not one that is
# faked up with symlink names.
PWD= /bin/pwd
fi
}并没返值
调用何获取参数 T=$(gettop)
实际参数谢谢


查看完整回答
反对 回复 2022-07-24
  • 1 回答
  • 0 关注
  • 168 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号