Bash script that can output specific parts of a tacacs file into columns

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I'm trying to output parts of a tacacs file into a monthly report.



Have tried doing it in python but my result still has errors, so I thought I'd try and see if there's a elegant solution within a simple-ish bash script.



Among other things in the file, the bits that I want out of the file look like this:



user = user1 
member = group2


user = user2
member = group3



Now ideally what I want, is all the members that are part of say, group2, outputted into a column and in another column, have the name of the group they're in.



I can handle the emailing monthly part, it's just the output I'm experiencing issues with.



Any ideas?










share|improve this question

























    up vote
    -1
    down vote

    favorite












    I'm trying to output parts of a tacacs file into a monthly report.



    Have tried doing it in python but my result still has errors, so I thought I'd try and see if there's a elegant solution within a simple-ish bash script.



    Among other things in the file, the bits that I want out of the file look like this:



    user = user1 
    member = group2


    user = user2
    member = group3



    Now ideally what I want, is all the members that are part of say, group2, outputted into a column and in another column, have the name of the group they're in.



    I can handle the emailing monthly part, it's just the output I'm experiencing issues with.



    Any ideas?










    share|improve this question























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I'm trying to output parts of a tacacs file into a monthly report.



      Have tried doing it in python but my result still has errors, so I thought I'd try and see if there's a elegant solution within a simple-ish bash script.



      Among other things in the file, the bits that I want out of the file look like this:



      user = user1 
      member = group2


      user = user2
      member = group3



      Now ideally what I want, is all the members that are part of say, group2, outputted into a column and in another column, have the name of the group they're in.



      I can handle the emailing monthly part, it's just the output I'm experiencing issues with.



      Any ideas?










      share|improve this question













      I'm trying to output parts of a tacacs file into a monthly report.



      Have tried doing it in python but my result still has errors, so I thought I'd try and see if there's a elegant solution within a simple-ish bash script.



      Among other things in the file, the bits that I want out of the file look like this:



      user = user1 
      member = group2


      user = user2
      member = group3



      Now ideally what I want, is all the members that are part of say, group2, outputted into a column and in another column, have the name of the group they're in.



      I can handle the emailing monthly part, it's just the output I'm experiencing issues with.



      Any ideas?







      linux bash columns output






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 26 '17 at 21:41









      Puzzleduser135

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          $ awk '/user =/ u = $3 /member =/ print u, $3 ' file
          user1 group2
          user2 group3


          If we find a line matching user =, then remember the user name (this is take from the third whitespace-delimited field). When we find a line matching member =, output the remembered user name along with the third field from this line (which ought to be the group name).



          I'm unfamiliar with the file format and I don't know what else may be present in this file, so I can't say that this would work on any other data than what's presented in the question.






          share|improve this answer




















          • That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
            – Puzzleduser135
            Sep 26 '17 at 22:42










          • Good! If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Sep 27 '17 at 20:23










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f394638%2fbash-script-that-can-output-specific-parts-of-a-tacacs-file-into-columns%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          $ awk '/user =/ u = $3 /member =/ print u, $3 ' file
          user1 group2
          user2 group3


          If we find a line matching user =, then remember the user name (this is take from the third whitespace-delimited field). When we find a line matching member =, output the remembered user name along with the third field from this line (which ought to be the group name).



          I'm unfamiliar with the file format and I don't know what else may be present in this file, so I can't say that this would work on any other data than what's presented in the question.






          share|improve this answer




















          • That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
            – Puzzleduser135
            Sep 26 '17 at 22:42










          • Good! If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Sep 27 '17 at 20:23














          up vote
          0
          down vote













          $ awk '/user =/ u = $3 /member =/ print u, $3 ' file
          user1 group2
          user2 group3


          If we find a line matching user =, then remember the user name (this is take from the third whitespace-delimited field). When we find a line matching member =, output the remembered user name along with the third field from this line (which ought to be the group name).



          I'm unfamiliar with the file format and I don't know what else may be present in this file, so I can't say that this would work on any other data than what's presented in the question.






          share|improve this answer




















          • That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
            – Puzzleduser135
            Sep 26 '17 at 22:42










          • Good! If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Sep 27 '17 at 20:23












          up vote
          0
          down vote










          up vote
          0
          down vote









          $ awk '/user =/ u = $3 /member =/ print u, $3 ' file
          user1 group2
          user2 group3


          If we find a line matching user =, then remember the user name (this is take from the third whitespace-delimited field). When we find a line matching member =, output the remembered user name along with the third field from this line (which ought to be the group name).



          I'm unfamiliar with the file format and I don't know what else may be present in this file, so I can't say that this would work on any other data than what's presented in the question.






          share|improve this answer












          $ awk '/user =/ u = $3 /member =/ print u, $3 ' file
          user1 group2
          user2 group3


          If we find a line matching user =, then remember the user name (this is take from the third whitespace-delimited field). When we find a line matching member =, output the remembered user name along with the third field from this line (which ought to be the group name).



          I'm unfamiliar with the file format and I don't know what else may be present in this file, so I can't say that this would work on any other data than what's presented in the question.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 26 '17 at 22:17









          Kusalananda

          106k14209327




          106k14209327











          • That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
            – Puzzleduser135
            Sep 26 '17 at 22:42










          • Good! If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Sep 27 '17 at 20:23
















          • That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
            – Puzzleduser135
            Sep 26 '17 at 22:42










          • Good! If this solves your issue, please consider accepting the answer.
            – Kusalananda
            Sep 27 '17 at 20:23















          That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
          – Puzzleduser135
          Sep 26 '17 at 22:42




          That works pretty well, I replaced member= with the group name and it returns everyone that is in that group. Is there anyway to add formatting to both columns and add headers at the top?
          – Puzzleduser135
          Sep 26 '17 at 22:42












          Good! If this solves your issue, please consider accepting the answer.
          – Kusalananda
          Sep 27 '17 at 20:23




          Good! If this solves your issue, please consider accepting the answer.
          – Kusalananda
          Sep 27 '17 at 20:23

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394638%2fbash-script-that-can-output-specific-parts-of-a-tacacs-file-into-columns%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)