Ack & negative lookahead gives errors

I have a problem using ack-grep with a negative outlook.

I run this command:

 ack-grep "paypal_responded(?!_at)" 

but I get an error:

 bash: !_at: event not found 

I tried to add a backslash in different places, but I am also new to using ack and linux, so please treat me as a newbie with any instructions.

Thanks in advance.

+10
command-line linux ack
Dec 05 2018-11-12T00:
source share
2 answers

Try ack-grep 'paypal_responded(?!_at)'

You need a single quote to avoid bash interpreting ! as a story expansion team.

+16
Dec 05 2018-11-12T00:
source share

The shell interprets ! in your input as a replacement for the command:

 $ ack-grep root /etc/passwd root:x:0:0:root:/root:/bin/bash $ !ac ack-grep root /etc/passwd root:x:0:0:root:/root:/bin/bash $ 

You need to tell the shell that ! doesn't really matter; There are two ways to do this:

 ack-grep "paypal_responded(?\!_at)" 

Strike>

 ack-grep "paypal_responded\(?\!_at\)" 

or

 ack-grep 'paypal_responded(?!_at)' 

Single-quoted strings have fewer uses for them:

 $ ack-grep "s\!" /etc/passwd $ ack-grep 's!' /etc/passwd $ 
+4
Dec 05 '11 at 12:10
source share



All Articles