• create two blank files data.txt and myipaddress.txt so you wont get "files does not exist error " once you have created the two blank files run the script and you should see your ipaddress in the file myipaddress.txt. cat myipaddress.txt simple and effective

    rm data.txt; rm myipaddress.txt; /sbin/ifconfig | grep "Bcast" >> data.txt ; cut -c21-35 data.txt >> myipaddress.txt

    Answered by ken smith
    5 years ago
    1 0
  • I like using awk for this kind of stuff:

    ifconfig | grep Bcast | awk -F ":" '{print $2}' | awk -F " " '{print $1}'>myipaddress.txt

    Answered by Olivier
    5 years ago
    0 2
  • You could also do it this way,

    ifconfig | grep 'inet addr' | cut -d":" -f2 | cut -d" " -f1 > ipaddress.txt

    Answered by Jesse Michelsen
    4 years ago
    1 0
Please register/login to answer this question. Click here to login
Questions from category Hardware

Community Answers - Search

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board