Arithmetic Operations in SHELL Script Example

SHELL Script Example: arithmetic operation in shell script

SHELL Script Example: how to do arithmetic operation in shell script?

create a file named "shell-script-example-arithmetic-tutorial.sh" then copy and paste the below code:

#!/bin/bash

FirstNumber=500;

SecondNumber=10;

Result=$((FirstNumber+SecondNumber));

echo "FirstNumber={$FirstNumber}, SecondNumber={$SecondNumber}, sum={$Result}";

SHELL Script Example: arithmetic operation in shell script?

Now run the program (shell-script-example-arithmetic-tutorial.sh) from shell command prompt & get the result as follows:

SHELL Script Example: arithmetic operation in shell script - output in the shell command prompt

The result in the windows command prompt

 

Related Tutorial Examples

  1. Unix wc-l Equivalent DOS Command Using C Program
  2. Parse Command Line Argument Input Using SHELL Script
  3. AWK SHELL Script File Last Modification Information Changing Delimiter
  4. UNIX Command Example: spell - Display Spelling Mistake
  5. UNIX Command Example: sort - Sort contents of a File
  6. UNIX Command Example: tail - Read Last Portion of a file
  7. UNIX Command Example: more - Continuously read a file
  8. 20 Steps to Make CakePHP Blog Project
  9. 28 Tutorials to Learn Oracle
  10. 19 Examples to Learn MySQL

No comments:

Post a Comment

leave your comments here..