[colug-432] Question about grep and using " " in bash

Zach Villers zachvatwork at gmail.com
Wed Apr 15 11:43:11 EDT 2015


Thanks for the response;

If this is not just a contrived question to learn about
argument quoting,

   *Actually, I just wanted to make sure grep should be returning the same
data for that particular statement with or without quotes. *

 "find" is usually a more reliable way to
retrieve files matching criteria. For example, to see
everything under /usr/bin with the setuid bit set, you can
do the following:

find /usr/bin -perm -u+s

*Interestingly, the manual we are working through suggested using find with
the -perm switch but followed by 4000 would give the same result as -u+s,
which, of course, it does not. Which led me to question the assertion that
quotes were necessary for the grep of ls.*

Note that find works recursively, but you can limit its
depth with the -maxdepth option.

Take a look at the man page for "find" as it has tests
available for just about anything you can think of.

*Thanks again.*

On Wed, Apr 15, 2015 at 11:34 AM, Matt Meinwald <meinwald.1 at osu.edu> wrote:

> On 04/15/2015 08:51 AM, 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.
> >
> > Thanks!
> >
>
> If this is not just a contrived question to learn about
> argument quoting, "find" is usually a more reliable way to
> retrieve files matching criteria. For example, to see
> everything under /usr/bin with the setuid bit set, you can
> do the following:
>
> find /usr/bin -perm -u+s
>
> Note that find works recursively, but you can limit its
> depth with the -maxdepth option.
>
> Take a look at the man page for "find" as it has tests
> available for just about anything you can think of.
>
> _______________________________________________
> 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/e152ab38/attachment-0001.html 


More information about the colug-432 mailing list