About 5,340,000 results
Open links in new tab
  1. How can I add numbers in a Bash script? - Stack Overflow

    There's a trick, e.g. process substition, to bring the final value of "inside num" to "outside num". For integers: num=$((num1 + 2 + 3)) # ... Using the external expr utility. Note that this is only …

  2. Shell Script to Add Two Numbers {4 Practical Examples}

    Apr 26, 2025 · In this tutorial, we will show you a few methods to add two numbers in a Bash script. You will learn how to use expr and the built-in features of the Bash shell to calculate the …

  3. How to Sum Up Numbers in Bash [Explained With Examples]

    May 4, 2024 · In the following section, I will show how you can add integer and floating-point numbers using different methods. 1. Sum Up Integer Numbers. There are several ways to sum …

  4. scripting - how can I add (subtract, etc.) two numbers with bash ...

    Arithmetic in POSIX shells is done with $ and double parentheses (( )): You can assign from that; also note the $ operators on the variable names inside (()) are optional): There is also expr: In …

  5. How to Add Numbers in Bash - Delft Stack

    Feb 2, 2024 · This tutorial shows different ways of adding numbers in a bash script using expr, arithmetic expansion, bc and awk.

  6. ADD TWO NUMBERS IN SHELL SCRIPT - tutorialsinhand

    Feb 7, 2021 · Solution to add two numbers in shell script: In this blog, we will calculate add two numbers in shell script or Linux or Unix. At first, take two numbers from the user and then …

  7. Addition of Bash Variables [4+ Examples] - LinuxSimply

    Jan 23, 2024 · To add two variables in bash, you can use several commands or approaches. Here are some methods to perform variable addition: In this section, I have listed some examples of …

  8. Adding numbers in shell scripting - Stack Overflow

    Aug 12, 2015 · Aside of the "fi" at the end of your script (likely a copy-and-paste error?), the script looks correct, although it can be done easier: bash already has the capability to do calculation, …

  9. How to add an integer number and a float number in a bash shell script

    Jul 6, 2018 · Bash doesn't have floating-point types, but you can use a calculator such as bc: #!/bin/Bash. This doesn't work because the bash builtin math operator $(( )) only supports …

  10. shell - How to add arithmetic variables in a script - Unix & Linux ...

    Nov 7, 2012 · The answer needs to specify in which shell the code is valid. For instance in the bourne Shell ( sh ) only the following instructions are valid: a=$((a+num)) a=$(($a+$num))

  11. Some results have been removed
Refresh