0

We have multiple servers and i would like to print users list and access level using bash.

I tried below command but could not get exact result what i wanted to:

awk '/Allow root/{p=5} p > 0 {print $1; p--}' /etc/sudoers 

above command just give me five entries as below

## root abcd ghfd fcff 

but I should get the O/P as below:

UserList AccessLevel root ALL abcd !/usr/bin/* 

Can i get the output as above?

1 Answer 1

0

After doing so much experiments i am able to achieve it as close as possible by below command.

grep "ALL=(ALL)" /etc/sudoers | awk '{ print $1 "\t""\t""\t" $3 $4}' | cut -d '#' -f1 | cut -d '%' -f1 

and the output is as below:

xxxx ALL xxxxxx ALL xxxx ALL xxxx NOPASSWD:ALL abcd ALL xxxx ALL 

But still i am getting space separated output. i want to skip that spaces in output.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.