Match a pattern from File A to File B, and the matched lines to be written to File C [on hold]
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
.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?
command-line bash scripts text-processing grep
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.
add a comment |Â
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?
command-line bash scripts text-processing grep
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
add a comment |Â
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?
command-line bash scripts text-processing grep
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?
command-line bash scripts text-processing grep
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
add a comment |Â
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
add a comment |Â
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.
OP is usinggrep -w
, which is the same as surrounding each regex with word delimiters (b
).
â wjandrea
yesterday
add a comment |Â
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.
OP is usinggrep -w
, which is the same as surrounding each regex with word delimiters (b
).
â wjandrea
yesterday
add a comment |Â
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.
OP is usinggrep -w
, which is the same as surrounding each regex with word delimiters (b
).
â wjandrea
yesterday
add a comment |Â
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.
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.
answered 2 days ago
OkezieE
1034
1034
OP is usinggrep -w
, which is the same as surrounding each regex with word delimiters (b
).
â wjandrea
yesterday
add a comment |Â
OP is usinggrep -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
add a comment |Â
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