Regex equivalent to ! (not)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regex equivalent to ! (not)
# 1  
Old 01-26-2012
Regex equivalent to ! (not)

I want to have a regex line equivalent to the following:

Code:
!\bfalse\b

basically search for not exact string "false"
# 2  
Old 01-26-2012
using egrep:

Code:
egrep '!(\bfalse\b)'   myinputfile

This means reject lines which contain the word 'false', everything else is printed.
# 3  
Old 01-26-2012
Quote:
Originally Posted by streetfighter2
I want to have a regex line equivalent to the following:

Code:
!\bfalse\b

basically search for not exact string "false"
What cmd are you trying this for...
# 4  
Old 01-26-2012
Quote:
Originally Posted by shamrock
What cmd are you trying this for...
I'm actually using this command with a script that takes regular expressions as arguments.
# 5  
Old 01-26-2012
or grep -v if you don't have egrep available.
# 6  
Old 01-27-2012
Thanks for the response guys, I figured out that the script I was running the regex has an argument to "inverse regex" and that did the trick Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

4. Cybersecurity

chage -d equivalent

Hello all, I was wondering if there was a LINUX command equivalent of 'chage -d' on for the following UNIX flavors: HP-UX Solaris AIX I want to be able to change the aging for an account on each system without inadvertently expiring an account that is like with the "/bin/passwd -x" or... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

5. Shell Programming and Scripting

awk equivalent of regex

Hi all, Can someone tell me what's the (g)awk equal of this simple regex to find ip addresses in urls: egrep "^http://{1,3}\.{1,3}\.{1,3}\.{1,3}(:{1,5})?/"Input: http://10.0.0.1/query.exe http://11y10x09w:80/howaboutme http://192.168.100.190:1234/takeme.gpg Output:... (8 Replies)
Discussion started by: r4v3n
8 Replies

6. Shell Programming and Scripting

How to do equivalent of /(regexp){0}/ ?

I don't want to have to resort to /()/ though that does work. Effectively, I need to be able to implement /(?:(?:regexp1){0})(regexp2)\D/ to basically match regexp2 as long as it is present and regexp1 is NOT. So, how to do /(regexp){0}/ ? (2 Replies)
Discussion started by: Vi-Curious
2 Replies

7. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

8. HP-UX

lsof equivalent in HP-UX

I need lsof equivalent in HP-UX. I do not want to add lsof utility separately. (1 Reply)
Discussion started by: deo_kaustubh
1 Replies

9. Shell Programming and Scripting

ps ax equivalent in solaris

I am using "ps ax" command in one of my scripts . AIX has x flag for ps . is there any equilent command for ps ax in solaris ? Thanks (1 Reply)
Discussion started by: talashil
1 Replies

10. Solaris

Equivalent to locate

Does Solaris 10 have an equivalent to FreeBSD's `locate'? If not, what is the best way to search for files (allowing regexp) throughout the system? (5 Replies)
Discussion started by: Russell
5 Replies
Login or Register to Ask a Question