Using "lines starting with and line whose ( it contains "value") of file

(imported topic written by SystemAdmin)

I want to return the line: communication.managerid_1=ESP_PROD Specifically if it begins with communication.managerid AND containd ESP_PROD. The_1 could be another number or the line could be commented with a #, in that case would be false.

I tried to check existance using someting like this, but failed

exists line (starting with “communication.managerid”) and (whose (it contains “ESP_PROD”)) of file “/opt/dseries/WA/agentparm.txt”

The following works, but would not be correct if ESP_PRD was on a line beginning with a #communication.managerid

as the example does not compare both to a single line of the file

Q: exists line starting with “communication.managerid” of file “/opt/dseries/WA/agentparm.txt” and exists line whose (it contains “ESP_PROD”) of file “/opt/dseries/WA/agentparm.txt”

A: True

Sample file:

A: communication.managerid_1=ESP_PROD

A: communication.manageraddress_1=161.222.3.127

A: communication.managerport_1=7507

A: communication.monitorobject_1=UXPRD215/AGENTMON1.0/MAIN

A:

A: #communication.managerid_2=

A: #communication.manageraddress_2=

A: #communication.managerport_2=

A: #communication.monitorobject_2=UXPRD215/AGENTMON2.0/MAIN

(imported comment written by jeremylam)

Have you tried:

q: lines whose (it starts with "communication.managerid" AND it contains "ESP_PROD") of file "/opt/dseries/WA/agentparm.txt"

This will return the line that matches, but it may also return more than one line if more than one match; plus it will return a result if no lines match.

(imported comment written by SystemAdmin)

That is exactly what I need. Here are the results

Q: lines whose (it starts with “communication.managerid” AND it contains “ESP_PROD”) of file “/opt/dseries/WA/agentparm.txt”

A: communication.managerid_1=ESP_PROD

T: 1234

Q: exists lines whose (it starts with “communication.managerid” AND it contains “ESP_PROD”) of file “/opt/dseries/WA/agentparm.txt”

A: True

T: 330

Thanks