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
- String Operators | Shell Script
- Conditional Statements | Shell Script
- Bash Script to get Low Battery Alert in Linux
- Implementing Directory Management using Shell Script
- Write a bash script to print a particular line from a file
- Average of given numbers in Bash
- Introduction to Linux Shell and Shell Scripting
- Fibonacci Series in Bash
- Simple Calculator in Bash
- Making your own Linux Shell in C
- Bash program to find A to the power B
- Programs for printing different patterns in Bash
- Array Basics in Shell Scripting | Set 1
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.