dpk_wal
asked on
work on data in text file
Hi,
I have a 30,000 line text file from which I need to compile data.
I will use example,
say I have lines as below:
object-group network C
network-object host 10.57.31.66
network-object host 10.57.31.67
network-object host 10.80.40.201
network-object host 10.80.40.202
object-group network A
network-object 10.14.60.0 255.255.252.0
network-object 10.14.63.0 255.255.255.0
network-object 10.14.64.0 255.255.255.0
object-group network B
network-object host 10.13.5.116
network-object host 10.13.5.117
I need to do following [order of steps is not important; final result is]:
1. remove all occurance of network-object and object-group network; so the lines remains:
C
host 10.57.31.66
host 10.57.31.67
host 10.80.40.201
host 10.80.40.202
A
10.14.60.0 255.255.252.0
10.14.63.0 255.255.255.0
10.14.64.0 255.255.255.0
B
host 10.13.5.116
host 10.13.5.117
2. Now transform all subnet masks to slash (/) notation [only output from object A shown below].
Refer link http://www.mattwaddell.com/2008/08/26/slash-notation-for-subnet-masks-quick-reference/
10.14.60.0 22
10.14.63.0 24
10.14.64.0 24
3. Give name as host_ip or subnet_mask and have lines read as:
host_10_57_31_66 10.57.31.66
host_10_57_31_67 10.57.31.67
host_10_80_40_201 10.80.40.201
host_10_80_40_202 10.80.40.202
10_14_60_0_22 10.14.60.0/22
10_14_63_0_24 10.14.63.0/24
10_14_64_0_24 10.14.64.0/24
host_10_13_5_116 10.13.5.116
host_10_13_5_117 10.13.5.117
4. Finally using host_ip and/or subnet_mask and club with name as below:
host_10_57_31_66 10.57.31.66
host_10_57_31_67 10.57.31.67
host_10_80_40_201 10.80.40.201
host_10_80_40_202 10.80.40.202
10_14_60_0_22 10.14.60.0/22
10_14_63_0_24 10.14.63.0/24
10_14_64_0_24 10.14.64.0/24
host_10_13_5_116 10.13.5.116
host_10_13_5_117 10.13.5.117
set C address host_10_57_31_66
set C address host_10_57_31_67
set C address host_10_80_40_201
set C address host_10_80_40_202
set A address 10_14_60_0_22
set A address 10_14_63_0_24
set A address 10_14_64_0_24
set B address host_10_13_5_116
set B address host_10_13_5_117
Sorry for the long question.
Thank you for all the help.
I have a 30,000 line text file from which I need to compile data.
I will use example,
say I have lines as below:
object-group network C
network-object host 10.57.31.66
network-object host 10.57.31.67
network-object host 10.80.40.201
network-object host 10.80.40.202
object-group network A
network-object 10.14.60.0 255.255.252.0
network-object 10.14.63.0 255.255.255.0
network-object 10.14.64.0 255.255.255.0
object-group network B
network-object host 10.13.5.116
network-object host 10.13.5.117
I need to do following [order of steps is not important; final result is]:
1. remove all occurance of network-object and object-group network; so the lines remains:
C
host 10.57.31.66
host 10.57.31.67
host 10.80.40.201
host 10.80.40.202
A
10.14.60.0 255.255.252.0
10.14.63.0 255.255.255.0
10.14.64.0 255.255.255.0
B
host 10.13.5.116
host 10.13.5.117
2. Now transform all subnet masks to slash (/) notation [only output from object A shown below].
Refer link http://www.mattwaddell.com/2008/08/26/slash-notation-for-subnet-masks-quick-reference/
10.14.60.0 22
10.14.63.0 24
10.14.64.0 24
3. Give name as host_ip or subnet_mask and have lines read as:
host_10_57_31_66 10.57.31.66
host_10_57_31_67 10.57.31.67
host_10_80_40_201 10.80.40.201
host_10_80_40_202 10.80.40.202
10_14_60_0_22 10.14.60.0/22
10_14_63_0_24 10.14.63.0/24
10_14_64_0_24 10.14.64.0/24
host_10_13_5_116 10.13.5.116
host_10_13_5_117 10.13.5.117
4. Finally using host_ip and/or subnet_mask and club with name as below:
host_10_57_31_66 10.57.31.66
host_10_57_31_67 10.57.31.67
host_10_80_40_201 10.80.40.201
host_10_80_40_202 10.80.40.202
10_14_60_0_22 10.14.60.0/22
10_14_63_0_24 10.14.63.0/24
10_14_64_0_24 10.14.64.0/24
host_10_13_5_116 10.13.5.116
host_10_13_5_117 10.13.5.117
set C address host_10_57_31_66
set C address host_10_57_31_67
set C address host_10_80_40_201
set C address host_10_80_40_202
set A address 10_14_60_0_22
set A address 10_14_63_0_24
set A address 10_14_64_0_24
set B address host_10_13_5_116
set B address host_10_13_5_117
Sorry for the long question.
Thank you for all the help.
Do you still need help with this? It seems to overlap with your other project (:modify/sort data in text file").
ASKER
Yes, this overlaps only in the final part where I get address set with addresses.
Am expecting a new text file with possible more lines and hence requesting complete solution than just piece solutions.
This time I have use excel and text editors to replace/sort data; want an easier approach as it looks this effort would get replicated.
Thank you.
Am expecting a new text file with possible more lines and hence requesting complete solution than just piece solutions.
This time I have use excel and text editors to replace/sort data; want an easier approach as it looks this effort would get replicated.
Thank you.
ASKER
Any updates on this project.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much for working on this.
Am asking a favor here; can you also please look at two of my related questions to an earlier solution given by you.
Regards.
Am asking a favor here; can you also please look at two of my related questions to an earlier solution given by you.
Regards.
Post the links here and I will take a look.