Allign file based on field values Announcing the arrival of Valued Associate #679: Cesar...

What's the point in a preamp?

Autumning in love

Need a suitable toxic chemical for a murder plot in my novel

Jazz greats knew nothing of modes. Why are they used to improvise on standards?

Who can trigger ship-wide alerts in Star Trek?

If I can make up priors, why can't I make up posteriors?

Did the new image of black hole confirm the general theory of relativity?

Is it possible to ask for a hotel room without minibar/extra services?

Is there a service that would inform me whenever a new direct route is scheduled from a given airport?

What LEGO pieces have "real-world" functionality?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

What are the performance impacts of 'functional' Rust?

Cauchy Sequence Characterized only By Directly Neighbouring Sequence Members

Is there a documented rationale why the House Ways and Means chairman can demand tax info?

Area of a 2D convex hull

90's book, teen horror

How do you clear the ApexPages.getMessages() collection in a test?

How can you insert a "times/divide" symbol similar to the "plus/minus" (±) one?

How can I make names more distinctive without making them longer?

What is the largest species of polychaete?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Are my PIs rude or am I just being too sensitive?

What loss function to use when labels are probabilities?

Blender game recording at the wrong time



Allign file based on field values



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow to compare 2 files with common columns and then get the output file with columns from each fileAwk: How to merge the contents of lines which has duplicate ID in first fieldawk: print one line per field-1 value (distinct) where difference “field-2 - field-3” is minimumCreate a field that can store values calculated from values in another fileUsing AWK to combine filesHow to delete input field in AWK?Join two files, keep key order of first file and fill missing values with string 'null'Linux Compare two files on different field and print field 1 of first fileEscaping commas inside double quotes as field separator in awkAwk extract fields with multiple seperator





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have a file like below with two fields ending with *.alarms.gz and *.values.gz, want to allign the files like all the alarms.gz in first field and all the values.gz in second field. How can i achieve this.



Sample Input



    20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412_92E9EA3400B1CF41.values.gz 20190412.alarms.gz
20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz


Required output



20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190412_92E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz









share|improve this question





























    0















    I have a file like below with two fields ending with *.alarms.gz and *.values.gz, want to allign the files like all the alarms.gz in first field and all the values.gz in second field. How can i achieve this.



    Sample Input



        20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412_92E9EA3400B1CF41.values.gz 20190412.alarms.gz
    20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz


    Required output



    20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190412_92E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
    20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz









    share|improve this question

























      0












      0








      0








      I have a file like below with two fields ending with *.alarms.gz and *.values.gz, want to allign the files like all the alarms.gz in first field and all the values.gz in second field. How can i achieve this.



      Sample Input



          20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412_92E9EA3400B1CF41.values.gz 20190412.alarms.gz
      20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz


      Required output



      20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_92E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz









      share|improve this question














      I have a file like below with two fields ending with *.alarms.gz and *.values.gz, want to allign the files like all the alarms.gz in first field and all the values.gz in second field. How can i achieve this.



      Sample Input



          20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412_92E9EA3400B1CF41.values.gz 20190412.alarms.gz
      20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz


      Required output



      20190412.alarms.gz              20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_02E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_92E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_42E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190415_32E9EA3400B1CF41.values.gz
      20190412.alarms.gz 20190412_12E1EA3400B1CFA1.values.gz






      awk files






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 39 mins ago









      upkarupkar

      16319




      16319






















          1 Answer
          1






          active

          oldest

          votes


















          2














          Using awk match only those lines that are off the grid, i.e. values in $1 and alarms in $2 and swap the column values. The {..}1 re-constructs the whole line with any modifications done inside the {..} and any change to the field/record separators.



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t


          The part column -t is just for pretty printing the output of awk. You could use the printf() with appropriate widths, but the former command makes the job easier.



          But on a POSIX complaint only awk, use printf()



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp; } 
          { printf "%s%40sn",$1,$2}' file


          If you were to make the changes in-line and using GNU awk less than 4.1.2, use a temporary file for re-direct the contents out of it



          tmpfile=$(mktemp)

          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file |
          column -t > "$tmpfile" && mv "$tmpfile" file


          or use the magical sponge tool from moreutils package ( On RHEL, do yum install moreutils)



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t |
          sponge file





          share|improve this answer





















          • 1





            Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

            – upkar
            13 mins ago












          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512481%2fallign-file-based-on-field-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Using awk match only those lines that are off the grid, i.e. values in $1 and alarms in $2 and swap the column values. The {..}1 re-constructs the whole line with any modifications done inside the {..} and any change to the field/record separators.



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t


          The part column -t is just for pretty printing the output of awk. You could use the printf() with appropriate widths, but the former command makes the job easier.



          But on a POSIX complaint only awk, use printf()



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp; } 
          { printf "%s%40sn",$1,$2}' file


          If you were to make the changes in-line and using GNU awk less than 4.1.2, use a temporary file for re-direct the contents out of it



          tmpfile=$(mktemp)

          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file |
          column -t > "$tmpfile" && mv "$tmpfile" file


          or use the magical sponge tool from moreutils package ( On RHEL, do yum install moreutils)



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t |
          sponge file





          share|improve this answer





















          • 1





            Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

            – upkar
            13 mins ago
















          2














          Using awk match only those lines that are off the grid, i.e. values in $1 and alarms in $2 and swap the column values. The {..}1 re-constructs the whole line with any modifications done inside the {..} and any change to the field/record separators.



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t


          The part column -t is just for pretty printing the output of awk. You could use the printf() with appropriate widths, but the former command makes the job easier.



          But on a POSIX complaint only awk, use printf()



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp; } 
          { printf "%s%40sn",$1,$2}' file


          If you were to make the changes in-line and using GNU awk less than 4.1.2, use a temporary file for re-direct the contents out of it



          tmpfile=$(mktemp)

          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file |
          column -t > "$tmpfile" && mv "$tmpfile" file


          or use the magical sponge tool from moreutils package ( On RHEL, do yum install moreutils)



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t |
          sponge file





          share|improve this answer





















          • 1





            Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

            – upkar
            13 mins ago














          2












          2








          2







          Using awk match only those lines that are off the grid, i.e. values in $1 and alarms in $2 and swap the column values. The {..}1 re-constructs the whole line with any modifications done inside the {..} and any change to the field/record separators.



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t


          The part column -t is just for pretty printing the output of awk. You could use the printf() with appropriate widths, but the former command makes the job easier.



          But on a POSIX complaint only awk, use printf()



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp; } 
          { printf "%s%40sn",$1,$2}' file


          If you were to make the changes in-line and using GNU awk less than 4.1.2, use a temporary file for re-direct the contents out of it



          tmpfile=$(mktemp)

          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file |
          column -t > "$tmpfile" && mv "$tmpfile" file


          or use the magical sponge tool from moreutils package ( On RHEL, do yum install moreutils)



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t |
          sponge file





          share|improve this answer















          Using awk match only those lines that are off the grid, i.e. values in $1 and alarms in $2 and swap the column values. The {..}1 re-constructs the whole line with any modifications done inside the {..} and any change to the field/record separators.



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t


          The part column -t is just for pretty printing the output of awk. You could use the printf() with appropriate widths, but the former command makes the job easier.



          But on a POSIX complaint only awk, use printf()



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp; } 
          { printf "%s%40sn",$1,$2}' file


          If you were to make the changes in-line and using GNU awk less than 4.1.2, use a temporary file for re-direct the contents out of it



          tmpfile=$(mktemp)

          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file |
          column -t > "$tmpfile" && mv "$tmpfile" file


          or use the magical sponge tool from moreutils package ( On RHEL, do yum install moreutils)



          awk '$1 ~ /.*values.gz/ && $2 ~ /.*alarms.gz/ { tmp = $1; $1 = $2; $2 = tmp }1' file | 
          column -t |
          sponge file






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 11 mins ago

























          answered 29 mins ago









          InianInian

          5,4651531




          5,4651531








          • 1





            Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

            – upkar
            13 mins ago














          • 1





            Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

            – upkar
            13 mins ago








          1




          1





          Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

          – upkar
          13 mins ago





          Perfect, Thanks !!!. What does 1 in the last part of the 1 before single quotes means.

          – upkar
          13 mins ago


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512481%2fallign-file-based-on-field-values%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...