Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux shellscript中的${param}和${param$$}是什么意思_Linux_Shell_Unix_Db2 - Fatal编程技术网

Linux shellscript中的${param}和${param$$}是什么意思

Linux shellscript中的${param}和${param$$}是什么意思,linux,shell,unix,db2,Linux,Shell,Unix,Db2,我不熟悉shell脚本,但正在浏览一些现有脚本。我的理解力低于命令 db2 -x some command | read param param=${param## }; param=${param%% }; 任何人都可以通过引导了解bash手册页中的以下内容: ${parameter##word} Remove matching prefix pattern. The word is expanded to produce

我不熟悉shell脚本,但正在浏览一些现有脚本。我的理解力低于命令

db2 -x some command | read
    param
    param=${param## }; 
    param=${param%% };

任何人都可以通过引导了解bash手册页中的以下内容

${parameter##word}
          Remove matching prefix pattern.  The word is expanded to produce
          a pattern just as in pathname expansion.  If the pattern matches
          the beginning of the value of parameter, then the result of  the
          expansion  is  the expanded value of parameter with the shortest
          matching pattern (the ``#'' case) or the longest  matching  patâ
          tern  (the  ``##''  case)  deleted.  If parameter is @ or *, the
          pattern removal operation is applied to each positional  parameâ
          ter in turn, and the expansion is the resultant list.  If paramâ
          eter is an array variable subscripted with @ or *,  the  pattern
          removal  operation  is  applied  to  each member of the array in
          turn, and the expansion is the resultant list.

 ${parameter%%word}
          Remove matching suffix pattern.  The word is expanded to produce
          a pattern just as in pathname expansion.  If the pattern matches
          a trailing portion of the expanded value of parameter, then  the
          result  of the expansion is the expanded value of parameter with
          the shortest matching pattern (the ``%'' case)  or  the  longest
          matching  pattern  (the ``%%'' case) deleted.  If parameter is @
          or *, the pattern removal operation is  applied  to  each  posiâ
          tional  parameter  in  turn,  and the expansion is the resultant
          list.  If parameter is an array variable subscripted with  @  or
          *,  the  pattern  removal operation is applied to each member of
          the array in turn, and the expansion is the resultant list.

总之,记住你的例子,param=${param###};将从变量param中删除前导空格,${parameter%%word}将删除尾随空格

您可以自己学习。只需在每个命令后添加
echo“param now=${param}”
。或者使用shell调试功能,
set-x
将使变量值在跟踪输出中可见,
set+x
将关闭该功能。同时搜索参数子状态/编辑。祝你好运。你看过壳牌的说明书了吗?在
bash
中,答案在第3.5.3节。@Sheller谢谢,我会帮你的