I want to track only below:
I am using below, but it doesn't work:
I want to track only below:
I am using below, but it doesn't work:
$ cat file
=(root)NOPASSWD:/usr/bin/vim
=(ALL)NOPASSWD:/usr/bin/vim
=NOPASSWD:/usr/bin/vim
=(user)NOPASSWD:/usr/bin/vim
$ egrep '=(\(root\)|\(ALL\))?NOPASSWD' file
=(root)NOPASSWD:/usr/bin/vim
=(ALL)NOPASSWD:/usr/bin/vim
=NOPASSWD:/usr/bin/vim
This doesnt give any output, the file content is:
=(root)NOPASSWD:/usr/bin/vim
=(ALL)NOPASSWD:/usr/bin/vim
=NOPASSWD:/usr/bin/vim
=(user)NOPASSWD:/usr/bin/vim
< sudo.txt tr -d "[:blank:]" | egrep '=(\((ALL|root)\))?([[:alpha:]]+:)?/usr/bin/vim'
Explanation of the (\((ALL|root)\))?
:
The inner ( )
are for the |
scope: ALL OR root.
Then there are the literal parens \( \)
around it.
And then there are another ( )
around this for the ?
scope: match zero or once.
Note that the greedy .*
"match all" often matches too much.
This works.
Now how do i match below:
=(root)ALL
=(root:root)ALL
=(root)NOPASSWD:ALL
=(root:root)NOPASSWD:ALL
=(ALL)ALL
=(ALL:ALL)ALL
=ALL
=NOPASSWD:ALL
Quick hack: allow :
in addition to ALL
and root
, allow one or more instances with +
< sudo.txt tr -d "[:blank:]" | egrep '=(\((ALL|root|:)+\))?([[:alpha:]]+:)?ALL'
This is not 100% precise, because it would also match ALLroot rootALL ALLALL rootroot.
No output