I created a function and every time I execute the script it spawns thousands of processes until the box crashes. I am not sure what is going wrong. Any help is appreciated.
ping () {
for i in {1..254};
do
(ping -c1 -W1 10.0.0.$i)
done
while true;
do
read -rep $'What method do you want to use' method
if [ $method == "ping" ];
then
ping
else
echo "Wrong method"
done
if [ $method == "ping" ]should beif [ "$method" = ping ]. Expansions need to be quoted to prevent string-splitting and globbing; constant strings with values known not to contain literal spaces, glob characters, &c. don't. And==isn't a valid operator intest-- bash offers it as an extension, which is why your code is working when you test it, but POSIX only specifies=.{}button in the editor.(ping ...)contributed to the problem by running code in a subprocess, causing a fork -- otherwise this would have only had one process looping but not crashed the machine.