本文介绍了在减去2猛砸变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的脚本来减去2目录,但是 COUNT = 前pression不工作,什么是正确的语法?

 #!的/ usr / bin中/ env的庆典
FIRSTV =`LS -1 | WC -l`
CD ..
SECONDV =`LS -1 | WC -l`
COUNT = EXPR $ FIRSTV- $ SECONDV
回声$ COUNT


解决方案

您只需要围绕减号一点点额外的空格和反引号:

  COUNT =`$ EXPR FIRSTV  -  $ SECONDV`

I have the script below to subtract the counts of files between 2 directories but the COUNT= expression does not work, what is the correct syntax?

#!/usr/bin/env bash
FIRSTV=`ls -1 | wc -l`
cd ..
SECONDV=`ls -1 | wc -l`
COUNT=expr $FIRSTV-$SECONDV
echo $COUNT
解决方案

You just need a little extra whitespace around the minus sign, and backticks:

COUNT=`expr $FIRSTV - $SECONDV`

这篇关于在减去2猛砸变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 22:18