SED: edit ip address
Hi, I'm trying to figure out how to use sed to modify a returned ip address from the command:
ifconfig eth1 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://' When run, this returns 10.69.69.1 I need help to rewrite this to return the network address in the form of: 10.69.69.0 Any help would greatly be appreciated. Thanks! John |
If it spits out "10.69.69.1" and you need "10.69.69.0" you could just append a piped "sed 's/1$/0/'
|
First, why is it returning the wrong address?
Second, do you need to change any digit in the last position to zero? (or just "1" to "0") |
Quote:
Code:
# ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/\([a-z]\+[:]\)// | sed -e 's/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/\1\.\2\.\3\.0/' |
Could you please be more specific as to what output you are getting and what you would like to modify it to?
|
All times are GMT -5. The time now is 12:22 PM. |