filmov
tv
Bash #14 - while / until loops (with port scan example)
Показать описание
In this video we'll go through while and until loops in bash scripting and test this using examples like a port scan.
#bashscripting #terminal
Related videos:
Used scripts:
#!/bin/bash
n=0
while [ $n -lt 9 ]
do
echo This number is less than 9: $n
((n++))
done
#!/bin/bash
n=0
until [ $n -gt 9 ]
do
echo This number is NOT greater than 9: $n
((n++))
done
#!/bin/bash
n=0
i=12
while [[ $n -lt 9 && i -lt 14 ]]
do
echo This number $n is less than 9 and this number $i is less than 14
((n++))
((i++))
done
Port scan script (angled brackets are removed, due to video description limitations):
#!/bin/bash
i=0
while [ $i -lt 5000 ]
do
(echo /dev/tcp/127.0.0.1/$i) &/dev/null && printf "Open Port at:$i" || printf "."
((++i))
done
Timestamp:
0:27 while & until loops in general
0:43 while loop with example
1:01 logical conditions
1:34 until loop with example
1:47 loops with multiple conditions
2:25 while loop with port scan
2:58 endless loops
#bashscripting #terminal
Related videos:
Used scripts:
#!/bin/bash
n=0
while [ $n -lt 9 ]
do
echo This number is less than 9: $n
((n++))
done
#!/bin/bash
n=0
until [ $n -gt 9 ]
do
echo This number is NOT greater than 9: $n
((n++))
done
#!/bin/bash
n=0
i=12
while [[ $n -lt 9 && i -lt 14 ]]
do
echo This number $n is less than 9 and this number $i is less than 14
((n++))
((i++))
done
Port scan script (angled brackets are removed, due to video description limitations):
#!/bin/bash
i=0
while [ $i -lt 5000 ]
do
(echo /dev/tcp/127.0.0.1/$i) &/dev/null && printf "Open Port at:$i" || printf "."
((++i))
done
Timestamp:
0:27 while & until loops in general
0:43 while loop with example
1:01 logical conditions
1:34 until loop with example
1:47 loops with multiple conditions
2:25 while loop with port scan
2:58 endless loops