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
- Bash shell script to find out the largest value from given command line arguments
- Bash Script to get Low Battery Alert in Linux
- Write a bash script to print a particular line from a file
- String Operators | Shell Script
- Conditional Statements | Shell Script
- Looping Statements | Shell Script
- Implementing Directory Management using Shell Script
- Automated Recursive Encryption in a Directory Using Shell Script
- Average of given numbers in Bash
- Introduction to Linux Shell and Shell Scripting
- Simple Calculator in Bash
- Fibonacci Series in Bash
- Bash program to find A to the power B
- Programs for printing different patterns in Bash
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.