Match a pattern from File A to File B, and the matched lines to be written to File C [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I have 2 files.



FileA having:



addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


FileB having: (Master file having all contents - Base file used for searching patterns from FileA)



Given variable agenciesLink is id:side-menu-button-7010
Given variable addAgencyBtn is xpath://a[@es-bdd-id="ps-agency-list-page-es
Given variable agencyNameTextField is name:agencyName
Given variable agencyIdTextField is name:agencyId
Given variable agencyTypeDropDown is name:agencyType
Given variable taxTypDropDown is name:taxType
Given variable emailAddressTextField is name:emailAddress


I would like to pick the patterns from File A, and if File B has 'pattern' matched, I would like to copy those lines into File C.



I tried:



grep -wf FileA FileB > FileC


but I see FileC having entries from 'pattern substring' as well, which I don't want.



For example:



Given variable **addAgencyBtn** is xpath://a[@es-bdd-id="ps-agency-list-page-es-heading-href-add-agency"]
Given variable **agenciesLink** is id:side-menu-button-7010
Given variable **agenciesLink** is xpath://md-content/div/div/nav/div/ul/li[8]/div/ul/li[1]/a
Given variable **agencyEmailAddressTextField** is xpath://input[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-input-emailAddress"]
Given variable **agencyEmailTypeDropdown** is xpath://select[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-2-select-emailType"]
Given variable agencyGblFiltTextField is xpath://input[@es-bdd-id="ps-agency-list-page-2-ps-agency-list-es-list-panel-es-panel-header-es-panel-actions-es-global-filter"]
Given variable agencyIdTextField is name:agencyId
Given variable agencyNameTextField is name:agencyName
Given variable **applications_firstNameTextField** is xpath: // **having substring match**
Given variable **applications_lastNameTextField** is xpath://input // **having substring match**
Given variable **businessOwnerFirstName** is xpath:// // **having substring match**
Given variable businessOwnerLastName is xpath://input // having substring match
Given variable businessOwnLastNameTextField is xpath://input[@es-bdd
Given variable capAddPlayerFirstNameTextField is xpath://input
Given variable capPlayerFirstNameTxtFld is xpath://input[@es-bdd-id='ps-player-


Can you please help me to find out what is going wrong here?







share|improve this question













put on hold as unclear what you're asking by wjandrea, K7AAY, Zanna, Kevin Bowen, Thomas 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    There are lines in File C that aren't in File B. How did that happen?
    – wjandrea
    2 days ago











  • What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
    – Zanna
    yesterday
















up vote
0
down vote

favorite












I have 2 files.



FileA having:



addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


FileB having: (Master file having all contents - Base file used for searching patterns from FileA)



Given variable agenciesLink is id:side-menu-button-7010
Given variable addAgencyBtn is xpath://a[@es-bdd-id="ps-agency-list-page-es
Given variable agencyNameTextField is name:agencyName
Given variable agencyIdTextField is name:agencyId
Given variable agencyTypeDropDown is name:agencyType
Given variable taxTypDropDown is name:taxType
Given variable emailAddressTextField is name:emailAddress


I would like to pick the patterns from File A, and if File B has 'pattern' matched, I would like to copy those lines into File C.



I tried:



grep -wf FileA FileB > FileC


but I see FileC having entries from 'pattern substring' as well, which I don't want.



For example:



Given variable **addAgencyBtn** is xpath://a[@es-bdd-id="ps-agency-list-page-es-heading-href-add-agency"]
Given variable **agenciesLink** is id:side-menu-button-7010
Given variable **agenciesLink** is xpath://md-content/div/div/nav/div/ul/li[8]/div/ul/li[1]/a
Given variable **agencyEmailAddressTextField** is xpath://input[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-input-emailAddress"]
Given variable **agencyEmailTypeDropdown** is xpath://select[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-2-select-emailType"]
Given variable agencyGblFiltTextField is xpath://input[@es-bdd-id="ps-agency-list-page-2-ps-agency-list-es-list-panel-es-panel-header-es-panel-actions-es-global-filter"]
Given variable agencyIdTextField is name:agencyId
Given variable agencyNameTextField is name:agencyName
Given variable **applications_firstNameTextField** is xpath: // **having substring match**
Given variable **applications_lastNameTextField** is xpath://input // **having substring match**
Given variable **businessOwnerFirstName** is xpath:// // **having substring match**
Given variable businessOwnerLastName is xpath://input // having substring match
Given variable businessOwnLastNameTextField is xpath://input[@es-bdd
Given variable capAddPlayerFirstNameTextField is xpath://input
Given variable capPlayerFirstNameTxtFld is xpath://input[@es-bdd-id='ps-player-


Can you please help me to find out what is going wrong here?







share|improve this question













put on hold as unclear what you're asking by wjandrea, K7AAY, Zanna, Kevin Bowen, Thomas 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    There are lines in File C that aren't in File B. How did that happen?
    – wjandrea
    2 days ago











  • What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
    – Zanna
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have 2 files.



FileA having:



addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


FileB having: (Master file having all contents - Base file used for searching patterns from FileA)



Given variable agenciesLink is id:side-menu-button-7010
Given variable addAgencyBtn is xpath://a[@es-bdd-id="ps-agency-list-page-es
Given variable agencyNameTextField is name:agencyName
Given variable agencyIdTextField is name:agencyId
Given variable agencyTypeDropDown is name:agencyType
Given variable taxTypDropDown is name:taxType
Given variable emailAddressTextField is name:emailAddress


I would like to pick the patterns from File A, and if File B has 'pattern' matched, I would like to copy those lines into File C.



I tried:



grep -wf FileA FileB > FileC


but I see FileC having entries from 'pattern substring' as well, which I don't want.



For example:



Given variable **addAgencyBtn** is xpath://a[@es-bdd-id="ps-agency-list-page-es-heading-href-add-agency"]
Given variable **agenciesLink** is id:side-menu-button-7010
Given variable **agenciesLink** is xpath://md-content/div/div/nav/div/ul/li[8]/div/ul/li[1]/a
Given variable **agencyEmailAddressTextField** is xpath://input[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-input-emailAddress"]
Given variable **agencyEmailTypeDropdown** is xpath://select[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-2-select-emailType"]
Given variable agencyGblFiltTextField is xpath://input[@es-bdd-id="ps-agency-list-page-2-ps-agency-list-es-list-panel-es-panel-header-es-panel-actions-es-global-filter"]
Given variable agencyIdTextField is name:agencyId
Given variable agencyNameTextField is name:agencyName
Given variable **applications_firstNameTextField** is xpath: // **having substring match**
Given variable **applications_lastNameTextField** is xpath://input // **having substring match**
Given variable **businessOwnerFirstName** is xpath:// // **having substring match**
Given variable businessOwnerLastName is xpath://input // having substring match
Given variable businessOwnLastNameTextField is xpath://input[@es-bdd
Given variable capAddPlayerFirstNameTextField is xpath://input
Given variable capPlayerFirstNameTxtFld is xpath://input[@es-bdd-id='ps-player-


Can you please help me to find out what is going wrong here?







share|improve this question













I have 2 files.



FileA having:



addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


FileB having: (Master file having all contents - Base file used for searching patterns from FileA)



Given variable agenciesLink is id:side-menu-button-7010
Given variable addAgencyBtn is xpath://a[@es-bdd-id="ps-agency-list-page-es
Given variable agencyNameTextField is name:agencyName
Given variable agencyIdTextField is name:agencyId
Given variable agencyTypeDropDown is name:agencyType
Given variable taxTypDropDown is name:taxType
Given variable emailAddressTextField is name:emailAddress


I would like to pick the patterns from File A, and if File B has 'pattern' matched, I would like to copy those lines into File C.



I tried:



grep -wf FileA FileB > FileC


but I see FileC having entries from 'pattern substring' as well, which I don't want.



For example:



Given variable **addAgencyBtn** is xpath://a[@es-bdd-id="ps-agency-list-page-es-heading-href-add-agency"]
Given variable **agenciesLink** is id:side-menu-button-7010
Given variable **agenciesLink** is xpath://md-content/div/div/nav/div/ul/li[8]/div/ul/li[1]/a
Given variable **agencyEmailAddressTextField** is xpath://input[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-input-emailAddress"]
Given variable **agencyEmailTypeDropdown** is xpath://select[@es-bdd-id="ps-agency-edit-page-es-panel-body-2-es-contacts-form-2-es-panel-body-es-email-edit-form-es-field-edit-2-select-emailType"]
Given variable agencyGblFiltTextField is xpath://input[@es-bdd-id="ps-agency-list-page-2-ps-agency-list-es-list-panel-es-panel-header-es-panel-actions-es-global-filter"]
Given variable agencyIdTextField is name:agencyId
Given variable agencyNameTextField is name:agencyName
Given variable **applications_firstNameTextField** is xpath: // **having substring match**
Given variable **applications_lastNameTextField** is xpath://input // **having substring match**
Given variable **businessOwnerFirstName** is xpath:// // **having substring match**
Given variable businessOwnerLastName is xpath://input // having substring match
Given variable businessOwnLastNameTextField is xpath://input[@es-bdd
Given variable capAddPlayerFirstNameTextField is xpath://input
Given variable capPlayerFirstNameTxtFld is xpath://input[@es-bdd-id='ps-player-


Can you please help me to find out what is going wrong here?









share|improve this question












share|improve this question




share|improve this question








edited yesterday
























asked 2 days ago









Prakash Mohan

61




61




put on hold as unclear what you're asking by wjandrea, K7AAY, Zanna, Kevin Bowen, Thomas 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by wjandrea, K7AAY, Zanna, Kevin Bowen, Thomas 2 days ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    There are lines in File C that aren't in File B. How did that happen?
    – wjandrea
    2 days ago











  • What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
    – Zanna
    yesterday












  • 1




    There are lines in File C that aren't in File B. How did that happen?
    – wjandrea
    2 days ago











  • What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
    – Zanna
    yesterday







1




1




There are lines in File C that aren't in File B. How did that happen?
– wjandrea
2 days ago





There are lines in File C that aren't in File B. How did that happen?
– wjandrea
2 days ago













What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
– Zanna
yesterday




What you showed for FileC is not what you really get from the samples of FileA and FileB shown, is it? Please show the real output from your sample, the output you actually want to get instead, and don't add any extra characters.
– Zanna
yesterday










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Regular expressions!



It's not apparent to me what your environment or use case is, however it sounds like you need to use regular expressions in file1.txt. Do you have full control over patterns in file1.txt? If so, change each line to be a regular expressions to define exactly what you want.



For example:
If you only want the full word to be matched do the following:



File1:



saddAgencyBtns
sagenciesLinks
sagencyEmailAddressTextFields
sagencyEmailTypeDropdowns
sagencyGblFiltTextFields


This will match any of those words that begin with a space and end with a space.



Cheat.
You can also cheat and literally add the spaces in file1.txt



 addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


It doesn't look like it but there's a single space surrounding each word. This can get pretty complicated depending on if the data you are working with is inconsistent... or very dirty.






share|improve this answer





















  • OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
    – wjandrea
    yesterday

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Regular expressions!



It's not apparent to me what your environment or use case is, however it sounds like you need to use regular expressions in file1.txt. Do you have full control over patterns in file1.txt? If so, change each line to be a regular expressions to define exactly what you want.



For example:
If you only want the full word to be matched do the following:



File1:



saddAgencyBtns
sagenciesLinks
sagencyEmailAddressTextFields
sagencyEmailTypeDropdowns
sagencyGblFiltTextFields


This will match any of those words that begin with a space and end with a space.



Cheat.
You can also cheat and literally add the spaces in file1.txt



 addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


It doesn't look like it but there's a single space surrounding each word. This can get pretty complicated depending on if the data you are working with is inconsistent... or very dirty.






share|improve this answer





















  • OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
    – wjandrea
    yesterday














up vote
0
down vote













Regular expressions!



It's not apparent to me what your environment or use case is, however it sounds like you need to use regular expressions in file1.txt. Do you have full control over patterns in file1.txt? If so, change each line to be a regular expressions to define exactly what you want.



For example:
If you only want the full word to be matched do the following:



File1:



saddAgencyBtns
sagenciesLinks
sagencyEmailAddressTextFields
sagencyEmailTypeDropdowns
sagencyGblFiltTextFields


This will match any of those words that begin with a space and end with a space.



Cheat.
You can also cheat and literally add the spaces in file1.txt



 addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


It doesn't look like it but there's a single space surrounding each word. This can get pretty complicated depending on if the data you are working with is inconsistent... or very dirty.






share|improve this answer





















  • OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
    – wjandrea
    yesterday












up vote
0
down vote










up vote
0
down vote









Regular expressions!



It's not apparent to me what your environment or use case is, however it sounds like you need to use regular expressions in file1.txt. Do you have full control over patterns in file1.txt? If so, change each line to be a regular expressions to define exactly what you want.



For example:
If you only want the full word to be matched do the following:



File1:



saddAgencyBtns
sagenciesLinks
sagencyEmailAddressTextFields
sagencyEmailTypeDropdowns
sagencyGblFiltTextFields


This will match any of those words that begin with a space and end with a space.



Cheat.
You can also cheat and literally add the spaces in file1.txt



 addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


It doesn't look like it but there's a single space surrounding each word. This can get pretty complicated depending on if the data you are working with is inconsistent... or very dirty.






share|improve this answer













Regular expressions!



It's not apparent to me what your environment or use case is, however it sounds like you need to use regular expressions in file1.txt. Do you have full control over patterns in file1.txt? If so, change each line to be a regular expressions to define exactly what you want.



For example:
If you only want the full word to be matched do the following:



File1:



saddAgencyBtns
sagenciesLinks
sagencyEmailAddressTextFields
sagencyEmailTypeDropdowns
sagencyGblFiltTextFields


This will match any of those words that begin with a space and end with a space.



Cheat.
You can also cheat and literally add the spaces in file1.txt



 addAgencyBtn
agenciesLink
agencyEmailAddressTextField
agencyEmailTypeDropdown
agencyGblFiltTextField


It doesn't look like it but there's a single space surrounding each word. This can get pretty complicated depending on if the data you are working with is inconsistent... or very dirty.







share|improve this answer













share|improve this answer



share|improve this answer











answered 2 days ago









OkezieE

1034




1034











  • OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
    – wjandrea
    yesterday
















  • OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
    – wjandrea
    yesterday















OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
– wjandrea
yesterday




OP is using grep -w, which is the same as surrounding each regex with word delimiters (b).
– wjandrea
yesterday


Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491