shell ${}

shell 中的${},##, %% , :- ,:+, ? 的使用 - 30岁再次出发 - 博客园

a.sh

#!/bin/sh

jsonfilter() {
	echo 999999999999999
 echo "1= ${1} 2 = ${2} 3=${3} 4=${4} 5= ${5} 6=${6}"
}

__network_ifstatus() {
jsonfilter ${4:+-F "$4"} ${5:+-l "$5"} -s "$__NETWORK_CACHE" -e "$1=@.interface${2:+[@.interface='$2']}$3"
}

#echo 88888888888888888

#__network_ifstatus "extiface" "" "[@.route[@.target='0.0.0.0' && !@.table]].interface" "88888888888888" 1

# 1: destination variable
# 2: addr
# 3: inactive
__network_wan()
{
        __network_ifstatus "$1" "" \
                "[@.route[@.target='$2' && !@.table]].interface" "" 1 && \
                        return 0

        [ "$3" = 1 -o "$3" = "true" ] && \
                __network_ifstatus "$1" "" \
                        "[@.inactive.route[@.target='$2' && !@.table]].interface" "" 1
}

# find the logical interface which holds the current IPv4 default route
# 1: destination variable
# 2: consider inactive default routes if "true" (optional)
network_find_wan() { __network_wan "$1" "0.0.0.0" "$2"; }

network_find_wan extiface

执行 a.sh

jj@ubuntu-rd540-3:~/tmp/jsonfilter$ ./a.sh 
999999999999999
1= -l 2 = 1 3=-s 4= 5= -e 6=extiface=@.interface[@.route[@.target='0.0.0.0' && !@.table]].interface

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值