get specific lines from File1, others from File2 and print them in File3Piping with Moreutils tsGrep strings...
Who deserves to be first and second author? PhD student who collected data, research associate who wrote the paper or supervisor?
How much attack damage does the AC boost from a shield prevent on average?
String reversal in Python
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
A question on the ultrafilter number
Why don't MCU characters ever seem to have language issues?
What are some noteworthy "mic-drop" moments in math?
BitNot does not flip bits in the way I expected
Why the color red for the Republican Party
Algorithm to convert a fixed-length string to the smallest possible collision-free representation?
Does "variables should live in the smallest scope as possible" include the case "variables should not exist if possible"?
How to pass a string to a command that expects a file?
Are babies of evil humanoid species inherently evil?
Why is there a voltage between the mains ground and my radiator?
If the Captain's screens are out, does he switch seats with the co-pilot?
Should QA ask requirements to developers?
Is it true that real estate prices mainly go up?
Good allowance savings plan?
How do I locate a classical quotation?
Do f-stop and exposure time perfectly cancel?
How much stiffer are 23c tires over 28c?
PTIJ: Why can't I eat anything?
Offered promotion but I'm leaving. Should I tell?
What is the likely impact of grounding an entire aircraft series?
get specific lines from File1, others from File2 and print them in File3
Piping with Moreutils tsGrep strings in a subgroup of lines in txt filePrint a string a number of timesdiffrence between two files of different row numbersSearch for number sequenceawk - compare files and print lines from both filesawk - compare 2 files and print columns from both filesReplace all lines between two patterns (inclusive) with a file contenthow to remove first N-1 lines up to a given input stringGet Non matching string from file1 to file2
I'm trying to get specific lines from File1, and others from File2 and print them in File3 (in consecutive order).
Let's say I need lines 1 and 3 from File1 and Lines 6 and 8 from File 2, then print them in File3.
I came up with this form:
grep -H 'x*' File1.txt File2.txt | sed '/File1.txt:[13]/d;/File2.txt:[68]/d;s/[^:]*://' > File3.txt
This deletes the 'unwanted' lines and print them in a third file, which works well for few lines, but with more lines it mixes them up in a weird way in the output file. In this example line 1 and 3 is: [13]), but I'll have hundreds or more lines, so I don't know how to separate different lines in the brackets (I know a 'comma' in between doesn't work).
I included File1 and File2 (to give an idea of my files). For instance, I'd need lines 19 to 40 from File1, and lines 9 to 18 from File2 printed in File3 (same order). Is there any other way of doing this that you can suggest?
I'd appreciate it.
Steph
grep sed awk
New contributor
add a comment |
I'm trying to get specific lines from File1, and others from File2 and print them in File3 (in consecutive order).
Let's say I need lines 1 and 3 from File1 and Lines 6 and 8 from File 2, then print them in File3.
I came up with this form:
grep -H 'x*' File1.txt File2.txt | sed '/File1.txt:[13]/d;/File2.txt:[68]/d;s/[^:]*://' > File3.txt
This deletes the 'unwanted' lines and print them in a third file, which works well for few lines, but with more lines it mixes them up in a weird way in the output file. In this example line 1 and 3 is: [13]), but I'll have hundreds or more lines, so I don't know how to separate different lines in the brackets (I know a 'comma' in between doesn't work).
I included File1 and File2 (to give an idea of my files). For instance, I'd need lines 19 to 40 from File1, and lines 9 to 18 from File2 printed in File3 (same order). Is there any other way of doing this that you can suggest?
I'd appreciate it.
Steph
grep sed awk
New contributor
add a comment |
I'm trying to get specific lines from File1, and others from File2 and print them in File3 (in consecutive order).
Let's say I need lines 1 and 3 from File1 and Lines 6 and 8 from File 2, then print them in File3.
I came up with this form:
grep -H 'x*' File1.txt File2.txt | sed '/File1.txt:[13]/d;/File2.txt:[68]/d;s/[^:]*://' > File3.txt
This deletes the 'unwanted' lines and print them in a third file, which works well for few lines, but with more lines it mixes them up in a weird way in the output file. In this example line 1 and 3 is: [13]), but I'll have hundreds or more lines, so I don't know how to separate different lines in the brackets (I know a 'comma' in between doesn't work).
I included File1 and File2 (to give an idea of my files). For instance, I'd need lines 19 to 40 from File1, and lines 9 to 18 from File2 printed in File3 (same order). Is there any other way of doing this that you can suggest?
I'd appreciate it.
Steph
grep sed awk
New contributor
I'm trying to get specific lines from File1, and others from File2 and print them in File3 (in consecutive order).
Let's say I need lines 1 and 3 from File1 and Lines 6 and 8 from File 2, then print them in File3.
I came up with this form:
grep -H 'x*' File1.txt File2.txt | sed '/File1.txt:[13]/d;/File2.txt:[68]/d;s/[^:]*://' > File3.txt
This deletes the 'unwanted' lines and print them in a third file, which works well for few lines, but with more lines it mixes them up in a weird way in the output file. In this example line 1 and 3 is: [13]), but I'll have hundreds or more lines, so I don't know how to separate different lines in the brackets (I know a 'comma' in between doesn't work).
I included File1 and File2 (to give an idea of my files). For instance, I'd need lines 19 to 40 from File1, and lines 9 to 18 from File2 printed in File3 (same order). Is there any other way of doing this that you can suggest?
I'd appreciate it.
Steph
grep sed awk
grep sed awk
New contributor
New contributor
New contributor
asked 2 mins ago
pollux7pollux7
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});
}
});
pollux7 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%2faskubuntu.com%2fquestions%2f1125209%2fget-specific-lines-from-file1-others-from-file2-and-print-them-in-file3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
pollux7 is a new contributor. Be nice, and check out our Code of Conduct.
pollux7 is a new contributor. Be nice, and check out our Code of Conduct.
pollux7 is a new contributor. Be nice, and check out our Code of Conduct.
pollux7 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1125209%2fget-specific-lines-from-file1-others-from-file2-and-print-them-in-file3%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