[colug-432] Question about grep and using " " in bash
Zach Villers
zachvatwork at gmail.com
Wed Apr 15 11:29:45 EDT 2015
Thanks for all of the responses. Sounds like the trainer was just trying to
impress good habits.
On Wed, Apr 15, 2015 at 11:01 AM, Rob Funk <rfunk at funknet.net> wrote:
> zach villers wrote:
> > Is there a difference between;
> >
> > ls -l | grep ^...s
> >
> > AND
> >
> > ls -l | grep "^...s"
> >
> > *trying to find files with setuid permission*
> >
> > A trainer told me using quotes with the grep statement was necessary,
> > but it doesn't seem to be.
>
> Without the quotes, the shell will try to interpret your search
> pattern in its own ways that have nothing to do with the search you're
> trying to do. In this case that's harmless (nothing for it to
> interpret), but if there are spaces or dollar signs or vertical-bars
> or ampersands or question marks or asterisks or
> less-than/greater-thans... and so on. There are many many symbols that
> might be in a regular expression that a shell might interpret itself.
> It's safest just to ALWAYS put it in quotes.
>
> Then there's the question of which quotes. With double-quotes, the
> shell will still try to interpret dollar-signs. You're safest using
> double-quotes.
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20150415/0e8447ee/attachment.html
More information about the colug-432
mailing list