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

Clash 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?
linux bash columns output
add a comment |Â
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?
linux bash columns output
add a comment |Â
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?
linux bash columns output
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
linux bash columns output
asked Sep 26 '17 at 21:41
Puzzleduser135
1
1
add a comment |Â
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
$ 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.
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
add a comment |Â
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
add a comment |Â
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
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
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
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
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