search for what is in file 1 in file 2 and output file 2 columnpassing file as a parameter with sed and...
Spoken encryption
Trying to build a function to compute divided difference for arbitrary list of points
AC contactor 1 pole or 2?
How much were the LMs maneuvered to their landing points?
Why didn't Britain or any other European power colonise Abyssinia/Ethiopia before 1936?
How can I stop myself from micromanaging other PCs' actions?
Basic Questions on Wiener Filtering
How can I prevent corporations from growing their own workforce?
Is dd if=/dev/urandom of=/dev/mem safe?
Keeping an "hot eyeball planet" wet
High income, sudden windfall
Marrying a second woman behind your wife's back: is it wrong and can Quran/Hadith prove this?
Assuring luggage isn't lost with short layover
Can I make a matrix from just a parts of the cells?
Unethical behavior : should I report it?
Problem in styling a monochrome plot
"I you already know": is this proper English?
What does コテッと mean?
Request for a Latin phrase as motto "God is highest/supreme"
Iterate over non-const variables in C++
How do I generate distribution of positive numbers only with min, max and mean?
How do campaign rallies gain candidates votes?
How do I run a game when my PCs have different approaches to combat?
Did the IBM PC use the 8088's NMI line?
search for what is in file 1 in file 2 and output file 2 column
passing file as a parameter with sed and looptwo .csv files compare using awkFile mapping reference from another fileUsing Diff on a specific column in a filecomparing the numbers and collecting details and providing output to new fileAWK Compare Column 1 from Two Files Print append column to third in outputHow to grep the rows with same column in different files and print specific column and add onto the original file?awk: find common data between two filesJoining two csv files on common column and removing the second last columncompare a certain number of lines between columns of two files
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Find for what is in file1 in file2 and the output should contain what is in file2, but the second column.
File1:
DataCreditoEAR.ear
PostSale.ear
File2:
DataCreditoEAR.ear /usr/DataCreditoEAR
DatacreditTableAdministrator.ear /usr/DatacreditTableAdministrator
PostSale.ear /usr/PostSale
Output:
/usr/DataCreditoEAR
/usr/PostSale
shell-script
New contributor
add a comment |
Find for what is in file1 in file2 and the output should contain what is in file2, but the second column.
File1:
DataCreditoEAR.ear
PostSale.ear
File2:
DataCreditoEAR.ear /usr/DataCreditoEAR
DatacreditTableAdministrator.ear /usr/DatacreditTableAdministrator
PostSale.ear /usr/PostSale
Output:
/usr/DataCreditoEAR
/usr/PostSale
shell-script
New contributor
add a comment |
Find for what is in file1 in file2 and the output should contain what is in file2, but the second column.
File1:
DataCreditoEAR.ear
PostSale.ear
File2:
DataCreditoEAR.ear /usr/DataCreditoEAR
DatacreditTableAdministrator.ear /usr/DatacreditTableAdministrator
PostSale.ear /usr/PostSale
Output:
/usr/DataCreditoEAR
/usr/PostSale
shell-script
New contributor
Find for what is in file1 in file2 and the output should contain what is in file2, but the second column.
File1:
DataCreditoEAR.ear
PostSale.ear
File2:
DataCreditoEAR.ear /usr/DataCreditoEAR
DatacreditTableAdministrator.ear /usr/DatacreditTableAdministrator
PostSale.ear /usr/PostSale
Output:
/usr/DataCreditoEAR
/usr/PostSale
shell-script
shell-script
New contributor
New contributor
edited 19 mins ago
Freddy
6,2911 gold badge6 silver badges24 bronze badges
6,2911 gold badge6 silver badges24 bronze badges
New contributor
asked 24 mins ago
Juan Javier Pinzon ReyesJuan Javier Pinzon Reyes
1
1
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The easiest/simplest way is to use grep
to do the pattern matching, and then awk
to extract the second field.
grep -f File1 File2 | awk '{print $2}'
If File1 contains fixed-strings rather than regexp patterns, use grep's -F
aka --fixed-strings
option:
grep -F -f File1 File2 | awk '{print $2}'
add a comment |
If the fields (columns) in File2 are delimited by tabs,
grep -f File1 File2 | cut -f2
otherwise,
grep -f File1 File2 | awk '{print $2}'
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Juan Javier Pinzon Reyes is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532534%2fsearch-for-what-is-in-file-1-in-file-2-and-output-file-2-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The easiest/simplest way is to use grep
to do the pattern matching, and then awk
to extract the second field.
grep -f File1 File2 | awk '{print $2}'
If File1 contains fixed-strings rather than regexp patterns, use grep's -F
aka --fixed-strings
option:
grep -F -f File1 File2 | awk '{print $2}'
add a comment |
The easiest/simplest way is to use grep
to do the pattern matching, and then awk
to extract the second field.
grep -f File1 File2 | awk '{print $2}'
If File1 contains fixed-strings rather than regexp patterns, use grep's -F
aka --fixed-strings
option:
grep -F -f File1 File2 | awk '{print $2}'
add a comment |
The easiest/simplest way is to use grep
to do the pattern matching, and then awk
to extract the second field.
grep -f File1 File2 | awk '{print $2}'
If File1 contains fixed-strings rather than regexp patterns, use grep's -F
aka --fixed-strings
option:
grep -F -f File1 File2 | awk '{print $2}'
The easiest/simplest way is to use grep
to do the pattern matching, and then awk
to extract the second field.
grep -f File1 File2 | awk '{print $2}'
If File1 contains fixed-strings rather than regexp patterns, use grep's -F
aka --fixed-strings
option:
grep -F -f File1 File2 | awk '{print $2}'
answered 9 mins ago
cascas
40.7k4 gold badges58 silver badges109 bronze badges
40.7k4 gold badges58 silver badges109 bronze badges
add a comment |
add a comment |
If the fields (columns) in File2 are delimited by tabs,
grep -f File1 File2 | cut -f2
otherwise,
grep -f File1 File2 | awk '{print $2}'
add a comment |
If the fields (columns) in File2 are delimited by tabs,
grep -f File1 File2 | cut -f2
otherwise,
grep -f File1 File2 | awk '{print $2}'
add a comment |
If the fields (columns) in File2 are delimited by tabs,
grep -f File1 File2 | cut -f2
otherwise,
grep -f File1 File2 | awk '{print $2}'
If the fields (columns) in File2 are delimited by tabs,
grep -f File1 File2 | cut -f2
otherwise,
grep -f File1 File2 | awk '{print $2}'
answered 3 mins ago
G-ManG-Man
15.2k9 gold badges43 silver badges80 bronze badges
15.2k9 gold badges43 silver badges80 bronze badges
add a comment |
add a comment |
Juan Javier Pinzon Reyes is a new contributor. Be nice, and check out our Code of Conduct.
Juan Javier Pinzon Reyes is a new contributor. Be nice, and check out our Code of Conduct.
Juan Javier Pinzon Reyes is a new contributor. Be nice, and check out our Code of Conduct.
Juan Javier Pinzon Reyes is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f532534%2fsearch-for-what-is-in-file-1-in-file-2-and-output-file-2-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown