Find the answer to your Linux question:
Results 1 to 3 of 3
Hi ALL have a file (called it A) contains; hostname 192.168.23.65 hostname 10.18.13.253 hostname 10.18.16.253 hostname 177.23.56.58 how can i write a script to get only ip addresses & send ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    5

    Thumbs down 0utput IP to a file

    Hi ALL

    have a file (called it A) contains;

    hostname 192.168.23.65
    hostname 10.18.13.253
    hostname 10.18.16.253
    hostname 177.23.56.58


    how can i write a script to get only ip addresses & send it to 3 files with the following info. only:

    file1:
    192.168.0.0

    file2:
    10.18.0.0

    file3:
    177.23.0.0


    by creating the 3 files then i will be able to set up subnetmask, gw,....etc.
    Thank you in advance.

  2. #2
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Code:
    awk '{print $2}' /var/tmp/ip.txt | awk -F "." '{print $1"."$2"."0"."0}' | sort -u
    This script doesn't produce your separate files. It constructs your unique netmasks, which you can redirect to a single file, then read each line and further redirect to separate files.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  3. #3
    Just Joined!
    Join Date
    Mar 2010
    Posts
    5
    Thanks NMSET. i will do that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...