Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Grep regular expression


Login or Register to Reply

 
Thread Tools Search this Thread
# 2  
Code:
$ 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


Last edited by anbu23; 3 Weeks Ago at 09:43 AM..
# 3  
This doesnt give any output, the file content is:

Code:
=(root)NOPASSWD:/usr/bin/vim
=(ALL)NOPASSWD:/usr/bin/vim
=NOPASSWD:/usr/bin/vim
=(user)NOPASSWD:/usr/bin/vim


Last edited by proactiveaditya; 3 Weeks Ago at 09:41 AM.. Reason: more details
# 4  
Code:
< 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.
# 5  
This works.

Now how do i match below:

Code:
=(root)ALL
=(root:root)ALL
=(root)NOPASSWD:ALL
=(root:root)NOPASSWD:ALL

=(ALL)ALL
=(ALL:ALL)ALL
=ALL
=NOPASSWD:ALL

# 6  
Quick hack: allow : in addition to ALL and root, allow one or more instances with +
Code:
< sudo.txt tr -d "[:blank:]" | egrep '=(\((ALL|root|:)+\))?([[:alpha:]]+:)?ALL'

This is not 100% precise, because it would also match ALLroot rootALL ALLALL rootroot.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Grep + Regular expression or
Anupam_Halder
Hi , I have few lines like A20120101.ANU.ZIP A20120401.ABC.ZIP A20120105.KJK.ZIP A20120809.JUG.ZIP A20120101.MAT.ZIP B20120301.ANU.XIP I want to filter by 1. Files starting with A and Ending With Z ( ^A.*.ZIP$) 2. And either ANU, or KJK or MAT in the file name. Hope my...... Shell Programming and Scripting
6
Shell Programming and Scripting
Help with grep / regular expression
dragon.1431
Hi, Input file: -13- -1er- -1xyz1- -1xz12- -2ab1- -2ab2-- -143- Code: grep '^*\-' input.txt Wrong output: -13- -1xyz1- -2ab1- -2ab2--... Shell Programming and Scripting
4
Shell Programming and Scripting
grep regular expression
Calypso
please can someone tell me what the following regrex means grep "^aa*$" <file> I thought this would match any word beginning with aa and ending with $, but it doesnt. Thanks in advance Calypso... Shell Programming and Scripting
7
Shell Programming and Scripting
grep with regular expression
daikeyang
Hi, guys. I have one question, hope somebody can give me a hand I have a file called passwd, the contents of it arebelow: *********************** ... goldsimj:x:5008:200: goldsij2:x:5009:200: whitej:x:5010:201: brownj:x:5011:202: goldsij3:x:5012:204: greyp:x:5013:203: ......... Shell Programming and Scripting
6
Shell Programming and Scripting
regarding grep regular expression
ukatru
When i do ls -ld RT_BP* i am getting the following list. drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP809 drwxrwx--- 2user group 256 Oct 17 10:09 RT_BP809.O drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP810 drwxrwx--- 2user group 256 Oct...... UNIX for Advanced & Expert Users
2
UNIX for Advanced & Expert Users

Featured Tech Videos