Try this Bash syntax instead of trying to use an external program expr
:
count=$((FIRSTV-SECONDV))
BTW, the correct syntax of using expr
is:
count=$(expr $FIRSTV - $SECONDV)
But keep in mind using expr
is going to be slower than the internal Bash syntax I provided above.
More Related Contents:
- What does 2>&1 mean here?
- In the shell, what does ” 2>&1 ” mean?
- Difference between sh and Bash
- Pass commands as input to another command (su, ssh, sh, etc)
- Why do you need ./ (dot-slash) before executable or script name to run it in bash?
- Can I export a variable to the environment from a Bash script without sourcing it?
- Bash command line and input limit
- How to run the sftp command with a password from Bash script?
- “~/Desktop/test.txt: No such file or directory”
- How do I check if a directory exists in a Bash shell script?
- Checking from shell script if a directory contains files
- How to determine the current interactive shell that I’m in (command-line)
- How to suppress Terminated message after killing in bash?
- How to represent multiple conditions in a shell if statement?
- “Invalid Arithmetic Operator” when doing floating-point math in bash
- Copy folder recursively, excluding some folders
- Variable interpolation in the shell
- Piping tail output though grep twice
- How to go to each directory and execute a command?
- What does ” 2>&1 ” mean?
- What’s a concise way to check that environment variables are set in a Unix shell script?
- executing shell command in background from script [duplicate]
- How do I check if a directory exists or not in a Bash shell script?
- Waiting for background processes to finish before exiting script
- Variables as commands in Bash scripts
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- Print a file’s last modified date in Bash
- Validate date format in a shell script
- How can I convert tabs to spaces in every file of a directory?
- How to wait on all child (and grandchild etc) process spawned by a script