Optional argument to replace variable in bash script

view full story

http://stackoverflow.com – How can I pass an optional argument to a bash script that will replace an existing variable in the script? For example: #!/bin/bash #hostfinder.sh #Find hosts in current /24 network subnet=$(hostname -i | cut -d. -f1,2,3) for j in \ $(for i in $subnet.{1..255}; do host $i; done | grep -v not | cut -d" " -f5) do ping -c1 -w 1 $j; done | grep -i from | cut -d" " -f3,4,5 | tr ':' ' ' | \ sed -e 's/from/Alive:/' This will grab the IP of the current host, run a reverse lookup against possible neighbors, ping test any hostnames it finds, and display an output similar to this: Alive: host1. (HowTos)