PCRE negative lookahead

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PCRE negative lookahead
# 1  
Old 01-10-2011
PCRE negative lookahead

I have read many tutorials and cannot get this to work. I need to use pcre (because that is what the library in the software we are using uses) and pcregrep everything except /home from the /etc/fstab

pcregrep '(?!/home)' /etc/fstab

It returns the entire fstab (This is on a RHEL5 machine). What am i doing wrong. Is there any better way to do this with a Perl compatible regular expression


# 2  
Old 01-10-2011
Why not just use:
grep -v /home /etc/fstab

( or pcregrep -v /home /etc/fstab )

With negative lookahead try:
pcregrep '^(?!.*/home)' etc/fstab

Last edited by Scrutinizer; 01-10-2011 at 05:51 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Postfix - pcre

Hello. I need to test valid sender address. I have created a rule in main.cf : smtpd_sender_login_maps = pcre:/etc/postfix/sender_login_maps.pcre smtpd_sender_restrictions = reject_non_fqdn_sender, reject_unknown_sender_domain, reject_sender_login_mismatch THe file... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

3. Shell Programming and Scripting

PCRE string questions.

What is the string that would satisfy this expression: "^gs{3}$" ? What is an expression that would satisfy all these strings: csafaq.exe, csafbc.exe, asdfcd.exe? Also, To catch these files, : gdnus1862.exe gdnus10.exe gdnus250.exe gdnus2337.exe I am using this regex. :... (2 Replies)
Discussion started by: komputersman
2 Replies
Login or Register to Ask a Question

Featured Tech Videos