jcjunction
jcjunction

Reputation: 325

How to run grep in a shell script, but exclude $0

I'm writing a script to check if i have removed all my javascript debbugger statements.

the current line in the script is:

grep -R --exclude-dir=node_modules --exclude=$0 "debugger" .

when I run this script in the directory im in it always returns

./debugger-checker.sh:4:grep --color=auto -nr --exclude-dir=node_modules --exclude=$0 "debugger" .

how can do you make grep exclude the shell script that is running it??

Upvotes: 0

Views: 521

Answers (1)

Vrata Blazek
Vrata Blazek

Reputation: 464

You can try this:

grep -R --exclude-dir=node_modules "debugger" . | grep -v $0

Upvotes: 1

Related Questions