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
- String Operators | Shell Script
- Looping Statements | Shell Script
- Conditional Statements | Shell Script
- 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
- A Shell program To Find The GCD | Linux
- Basic Operators in Shell Scripting
- Developing a Linux based shell
- Reverse a String | Shell Programming
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.