migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
20
automation-sys320/week09/IPList.bash
Normal file
20
automation-sys320/week09/IPList.bash
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# list all ips in given network prefix, /24 only
|
||||
|
||||
|
||||
# usage: bash IPList.bash 10.0.17
|
||||
[ $# -lt 1 ] && echo "Usage: $0 <Prefix>" && exit 1
|
||||
|
||||
#prefix is the first input taken
|
||||
prefix=$1
|
||||
|
||||
[ ${#prefix} -lt 5 ] && \
|
||||
printf "Prefix length is too short\nPrefix example: 10.0.17\n" && \
|
||||
exit 1
|
||||
|
||||
for i in {1..254}
|
||||
do
|
||||
ping -c 1 $prefix.$i | grep "64 bytes from *" | \
|
||||
grep -o $prefix.$i
|
||||
done
|
11
automation-sys320/week09/myIP.bash
Normal file
11
automation-sys320/week09/myIP.bash
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
# display ONLY IP address
|
||||
# output ip addr command
|
||||
# grep for enabled interfaces
|
||||
# grep to narrow in on IP
|
||||
# use tr to delete extra letters and spaces from output
|
||||
ip address | grep 'state UP' -A 3 | grep -o 'inet.*brd' | tr -d 'a-z '
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue