$* 将命令后面的参数理解为一个类似为字符串,[email protected]理解为多个单个的参数,类似理解成数据 [[email protected] test]# ./test4.sh jskd sj21 2 2 1 34 Using the $* method :jskd sj21 2 2 1 34 Using the [email protected] method :jskd sj21 2 2 1 34 ------------------------------ $* parameter # = jskd sj21 2 2 1 34 [email protected] Parameter #count = jskd [email protected] Parameter #count = sj21 [email protected] Parameter #count = 2 [email protected] Parameter #count = 2 [email protected] Parameter #count = 1 [email protected] Parameter #count = 34 [[email protected] test]#
#!/bin/bash #testing $* and [email protected] echo "Using the \$* method :$*" echo "Using the \[email protected] method :[email protected]" echo ------------------------------ for param in "$*" do echo "\$* parameter #$count = $param " count=$[ $count + 1 ] done count=1 for param in "[email protected]" do echo "\[email protected] Parameter #count = $param" count=$[ $count + 1 ] done ~
if [ str1 = str2 ] 当两个串有相同内容、长度时为真
if [ str1 != str2 ] 当串str1和str2不等时为真
if [ -n str1 ] 当串的长度大于0时为真(串非空)
if [ -z str1 ] 当串的长度为0时为真(空串)
if [ str1 ] 当串str1为非空时为真
时间: 2024-07-31 14:26:36