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

Matt Meinwald meinwald.1 at osu.edu
Wed Apr 15 11:34:52 EDT 2015


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.



More information about the colug-432 mailing list