Given two numbers and the task is to swap them using the third variable.
Input: first = 2, second = 4 Output: first = 4, second = 2 Input: first = 5, second = 7 Output: first = 7, second = 5
- Store the value of the first number into a temp variable.
- Store the value of the second number in the first number.
- Store the value of temp into the second variable.
After swapping, numbers are: first = 10, second = 5
How to execute the bash files?
- Write the bash code into a file and save that file with .sh extension i.e. filename.sh
- Open terminal and execute the file using below command:
- Bash shell script to find sum of digits
- Looping Statements | Shell Script
- Conditional Statements | Shell Script
- String Operators | Shell Script
- Average of given numbers in Bash
- Bash program to check if the Number is a Prime or not
- Fibonacci Series in Bash
- Bash program to find A to the power B
- Bash program to check if the Number is a Palindrome
- Sorting an array in Bash using Bubble sort
- Simple Calculator in Bash
- Programs for printing different patterns in Bash
- Array Basics Shell Scripting | Set 2 (Using Loops)
- Array Basics in Shell Scripting | Set 1
- Basic Operators in Shell Scripting
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.