Linux.com

Answers
  • 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 kshim5
    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 Olibois
    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 jmichelsen
    4 years ago
    1 0
Please register/login to answer this question. Click here to login
Questions from category Hardware

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    15 Sep » 19 Sep - Virtual
    Details
  2. LFS220 Linux System Administration
    22 Sep » 25 Sep - Virtual
    Details
  3. LFS520 OpenStack Cloud Architecture and Deployment
    29 Sep » 02 Oct - Costa Mesa
    Details

View All Upcoming Courses

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