I am trying to print the lines having specific strings only from multiple strings. I tried below code using enumerate and its work, but i want to check for multiple string to find out the lines.
Sample Data
ctive fint-upload-report "remotehost"\n', 'interface ethernet 0\n', ' ip address 10.64.81.5 255.255.255.240\n', ' no trapenable\n', ' exit\n', 'ip address 10.64.81.5 255.255.255.240\n', 'ip domainname localdomain\n', 'ipv6 domainname localdomain\n', 'ntp server 172.16.0.10\n', 'timezone Asia Calcutta\n', '! Iptables Configuration\n', '!PTP Configuration\n', 'ConnectPtpVersion 1\n', 'ConnectPtp 3 "1/3/1" norm mib 7 51380481 3 -1 303\n', 'ConnectPtp 3 "1/3/2" norm direct 7 50331904 10 -1 301\n', '!PTP End\n', '\n', 'rlnode radioLinkPtpNodeObjects 2\n', 'rlnode boardParameters 1 3 1 \n', '! CF configuration\n', 'config_file_name BKP_42106\n', '! command group end\n', '! SU configuration\n', 'su-activerelease 2\n', 'su-release CXP9010021_3 MINI-LINK_TN5.4FP3.2_LH1.6FP3.2_R32T102 1\n', 'su-release CXP9010021_1 MINI-LINK_TN_5.4FP.4_LH_1.6FP.4_R33C133 2\n', 'su-sbl_type 1 1\n', 'su-sbl_type 2 1\n', 'su-loadmodule CXCR102059_1 R11T01 1\n', 'su-loadmodule CXCR102051_1 R11T01 1\n', 'su-loadmodule CXCR102004_1 R6N03 1\n', 'su-loadmodule CXCR102050_1 R1G02 1\n', 'su-loadmodule CXP9011133_1 R16M13 1\n', 'su-loadmodule CXP9011133_2 R16M13 1\n', 'su-loadmodule CXP9011133_3 R16M13 1\n', 'su-loadmodule CXP9011133_4 R16M13 1\n', 'su-loadmodule CXP9011133_5 R16M13 1\n', 'su-loadmodule CXP9011133_6 R16M13 1\n', 'su-loadmodule CXP9011133_7 R7M19 1\n', 'su-loadmodule CXP9011133_9 R7M19 1\n', 'su-loadmodule CXP9011133_20 R7M19 1\n', 'su-loadmodule CXP9012118_1 R16M13 1\n', 'su-loadmodule CXC1725538_1 R1G03 1\n', 'su-loadmodule CXC1732476_1 R4M13 1\n', 'su-loadmodule CXC1731531_1 R2M02 1\n', 'su-loadmodule CXP9021456_1 R4A03 1\n', 'su-loadmodule CXP9014938_104 R32T102 1\n', 'su-loadmodule CXP9014938_105 R32T102 1\n', 'su-loadmodule CXP9012516_102 R32T102 1\n', 'su-loadmodule CXP9012516
import pandas
file = open ('2020_08_18_0000_NE.23152.GDNP11_1.10_64_81_5.0.txt').readlines()
Myindex = [l for l, elem in enumerate (file) if 'su-release' in elem]
for ind in Myindex:
line = file[ind]
print(line)
Output:
su-release CXP9010021_3 MINI-LINK_TN5.4FP3.2_LH1.6FP3.2_R32T102 1
su-release CXP9010021_1 MINI-LINK_TN_5.4FP.4_LH_1.6FP.4_R33C133 2