Shell Script (Bash) to Edit Output from a Command
I'm trying to make a shell script to determine the range of IP Addresses on my own personal wireless network. When I run this command:
ifconfig
I get this key information:
inet 192.168.1.228
broadcast 192.168.1.255
netmask 255.255.255.0
So now I know that the range is 192.168.1.0-255 (or 192.168.1.0/24). I tried to run this script I made:
#!/bin/bash
ifconfig | awk '/broadcast/ {print $6}'
This will output my max ip range:
192.168.1.255
How can I make this script find my max range like this but instead it writes it like this:
192.168.1.0-255
or
192.168.1.0/24
Any help is much appreciated!
grep 'broadcast' | awk '{print $6}'
doesn't make much sense.awk '/broadcast/ {print $6}'
192.168.1.224/27
based on the information you have provided.