shell script code to swap 2 numbers


swap()
{
echo "Enter num1"
read num1
echo "Enter num2"
read num2

temp=$num1
num1=$num2
num2=$temp
echo "swapping numbers"
echo "num1 is $num1"
echo "num2 is $num2"
}
swap


/*
@linux-ogus:~/Desktop> chmod 755 ex2
@linux-ogus:~/Desktop> ./ex2
Enter num1
20
Enter num2
30
swapping numbers
num1 is 30
num2 is 20
*/

0 comments :