What is the difference between running a script file like this:
sh myfile.sh
Or this:
./myfile.sh
I thought they are the same thing, but noticed sometimes they are not, as seen below example:
root@kali:~/Documents# sh sweep-ips.sh
ips range:
ping: 10.11.1.{0..24}: Name or service not known
root@kali:~/Documents# ./sweep-ips.sh
ips range:
64 bytes from 10.11.1.5: icmp_seq=1 ttl=128 time=242 ms
64 bytes from 10.11.1.8: icmp_seq=1 ttl=64 time=249 ms
64 bytes from 10.11.1.22: icmp_seq=1 ttl=255 time=249 ms
64 bytes from 10.11.1.24: icmp_seq=1 ttl=64 time=241 ms
script:
#!/bin/bash
echo "ips range"
for ip in 10.11.1.{0..24}
do
ping -c 1 ${ip} | grep "time="
done