How to swap two numbers in Linux Shell Script | Linux Shell Script
Jun 24, 2021
LinuxShellScript,
362 Views
How to swap two numbers in Linux Shell Script | Linux Shell Script
How to swap two numbers in Linux Shell Script | Linux Shell Script
We will create a shell script program to swap to numbers and then print both variables after swapping on the console screen.
#!/bin/bash
num1=25
num2=302
echo "Before Swapping"
echo "Num1: $num1"
echo "Num2: $num2"
num3=$num1
num1=$num2
num2=$num3
echo "After Swapping"
echo "Num1: $num1"
echo "Num2: $num2"