awk with sed to combine lines and remove specic odd pattern from line The 2019 Stack Overflow...

How do you keep chess fun when your opponent constantly beats you?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Mortgage adviser recommends a longer term than necessary combined with overpayments

Can a flute soloist sit?

Why can't devices on different VLANs, but on the same subnet, communicate?

Can the DM override racial traits?

Store Dynamic-accessible hidden metadata in a cell

Identify 80s or 90s comics with ripped creatures (not dwarves)

how can a perfect fourth interval be considered either consonant or dissonant?

How to make Illustrator type tool selection automatically adapt with text length

What do I do when my TA workload is more than expected?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Does Parliament hold absolute power in the UK?

Button changing its text & action. Good or terrible?

Working through the single responsibility principle (SRP) in Python when calls are expensive

Python - Fishing Simulator

How do spell lists change if the party levels up without taking a long rest?

Could an empire control the whole planet with today's comunication methods?

Can we generate random numbers using irrational numbers like π and e?

Do ℕ, mathbb{N}, BbbN, symbb{N} effectively differ, and is there a "canonical" specification of the naturals?

Are there continuous functions who are the same in an interval but differ in at least one other point?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Using dividends to reduce short term capital gains?



awk with sed to combine lines and remove specic odd pattern from line



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manarased to remove all whitespace from a lineJoin two lines with awk or sedsed: replace each occurence of 4 spaces (at beginning of a line) with 2 spacesRemoving first line with pattern with _both_ awk and sedSed/Awk line doubleusing sed to replace 1 line with a multi-line variable in kshUnable to get accurate record count of a csv fileHow copy or display unique entries from two text files in linux or in windowsReplace lines after a given number of matches on separate lines with AWKawk statement to validate and return fixed-structure data lines at start of file





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line in the block and is unique to each. There will always be a newline seperating the blocks and that line FileName_ID is not processed only printed. It is possible that there is noting above the FileName_ID and if this happens then it is also printed as is.



file



00-0000-Lname-Fname-REPEAT
xxxx_0001 xxxx_0002
111111-yyyy
xxxx_0003 xxxx_0008
111111-yyyy-0
xxxx_0009 xxxx_0006
FileName_ID

FileName_ID


desired



xxxx_0002 00-0000-Lname-Fname-REPEAT
xxxx_0008 111111-yyyy
xxxx_0006 111111-yyyy-0
FileName_ID

FileName_ID


awk



awk 'NR%2{printf "%s ",$0;next;}1' file | sed 's/xxxx_[0-9][0-9][0-9][13579]//g'









share|improve this question































    0















    In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line in the block and is unique to each. There will always be a newline seperating the blocks and that line FileName_ID is not processed only printed. It is possible that there is noting above the FileName_ID and if this happens then it is also printed as is.



    file



    00-0000-Lname-Fname-REPEAT
    xxxx_0001 xxxx_0002
    111111-yyyy
    xxxx_0003 xxxx_0008
    111111-yyyy-0
    xxxx_0009 xxxx_0006
    FileName_ID

    FileName_ID


    desired



    xxxx_0002 00-0000-Lname-Fname-REPEAT
    xxxx_0008 111111-yyyy
    xxxx_0006 111111-yyyy-0
    FileName_ID

    FileName_ID


    awk



    awk 'NR%2{printf "%s ",$0;next;}1' file | sed 's/xxxx_[0-9][0-9][0-9][13579]//g'









    share|improve this question



























      0












      0








      0








      In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line in the block and is unique to each. There will always be a newline seperating the blocks and that line FileName_ID is not processed only printed. It is possible that there is noting above the FileName_ID and if this happens then it is also printed as is.



      file



      00-0000-Lname-Fname-REPEAT
      xxxx_0001 xxxx_0002
      111111-yyyy
      xxxx_0003 xxxx_0008
      111111-yyyy-0
      xxxx_0009 xxxx_0006
      FileName_ID

      FileName_ID


      desired



      xxxx_0002 00-0000-Lname-Fname-REPEAT
      xxxx_0008 111111-yyyy
      xxxx_0006 111111-yyyy-0
      FileName_ID

      FileName_ID


      awk



      awk 'NR%2{printf "%s ",$0;next;}1' file | sed 's/xxxx_[0-9][0-9][0-9][13579]//g'









      share|improve this question
















      In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line in the block and is unique to each. There will always be a newline seperating the blocks and that line FileName_ID is not processed only printed. It is possible that there is noting above the FileName_ID and if this happens then it is also printed as is.



      file



      00-0000-Lname-Fname-REPEAT
      xxxx_0001 xxxx_0002
      111111-yyyy
      xxxx_0003 xxxx_0008
      111111-yyyy-0
      xxxx_0009 xxxx_0006
      FileName_ID

      FileName_ID


      desired



      xxxx_0002 00-0000-Lname-Fname-REPEAT
      xxxx_0008 111111-yyyy
      xxxx_0006 111111-yyyy-0
      FileName_ID

      FileName_ID


      awk



      awk 'NR%2{printf "%s ",$0;next;}1' file | sed 's/xxxx_[0-9][0-9][0-9][13579]//g'






      sed awk






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      cm0728

















      asked yesterday









      cm0728cm0728

      14419




      14419






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1424210%2fawk-with-sed-to-combine-lines-and-remove-specic-odd-pattern-from-line%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
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1424210%2fawk-with-sed-to-combine-lines-and-remove-specic-odd-pattern-from-line%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

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

          looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...