If I'm writing
grep -v "-NO" file
it says
grep: invalid option -- 'N'
So I need to write grep -v -- "-NO" file
or grep -v "\-NO" file
.
But why it recognizes the -
as option if it is in double quotes?
The quotes are removed by the shell before the arguments are passed to grep, in a step called Quote Removal. Also see Simple Command Expansion. So, really, grep
never sees these quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With