Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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
需要将bash脚本中GREP的输出保存为整数_Bash_Shell_Grep - Fatal编程技术网

需要将bash脚本中GREP的输出保存为整数

需要将bash脚本中GREP的输出保存为整数,bash,shell,grep,Bash,Shell,Grep,我试图获取变量中出现的“(”,然后在循环中使用它 尝试: LPC=$(grep -o "(" <<< $A | wc -l) while [ LPC -gt 0 ]; do 我似乎无法让它工作。您忘记了变量前面的美元符号 修改: while [ LPC -gt 0 ]; do 致: 您需要在LPC上执行参数替换: while[$LPC-gt 0];做该死的。你说得对。多谢 while [ LPC -gt 0 ]; do while [ $LPC -gt 0 ]; do

我试图获取变量中出现的“(”,然后在循环中使用它

尝试:

LPC=$(grep -o "(" <<< $A  | wc -l)

while [ LPC -gt 0 ]; do

我似乎无法让它工作。

您忘记了变量前面的美元符号

修改:

while [ LPC -gt 0 ]; do
致:


您需要在LPC上执行参数替换:


while[$LPC-gt 0];做

该死的。你说得对。多谢
while [ LPC -gt 0 ]; do
while [ $LPC -gt 0 ]; do