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













0















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









share







New contributor




pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    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









    share







    New contributor




    pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      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









      share







      New contributor




      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      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





      share







      New contributor




      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 mins ago









      pollux7pollux7

      1




      1




      New contributor




      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      pollux7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          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.










          draft saved

          draft discarded


















          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.










          draft saved

          draft discarded


















          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

          Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

          Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...