Shell Script to swap values in two variables x and y
Posted in Shell Math
#!/bin/bash # Shell Script to swap values in two variables x and y # ------------------------------------------------------------------------- # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- echo "Enter value for x : " read x echo "Enter value for y : " read y echo "Before swap, x = $x and y = $y" z=$x x=$y y=$z echo "After swap, x = $x and y = $y"
Download - Email this to a friend - Printable version
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bash shell script, mathematics, read command, swap values, swap variables, variables ~ Last updated on: April 9, 2008

