dumb question

Patrick O'Callaghan pocallaghan at gmail.com
Wed Jan 4 21:38:56 UTC 2012


On Wed, 2012-01-04 at 13:19 -0800, Paul Allen Newell wrote:
> On 1/4/2012 4:38 AM, Patrick O'Callaghan wrote:
> >
> > I know you and Ed (and Marvin) have been round the block on this, but if
> > you'll allow an oldie to sum up:
> >
> > Makefiles are not normally executables, in fact they aren't normally
> > Shell scripts. Therefore they don't need to have the +x attribute. It's
> > easy to list the Makefiles on your system and check this:
> >
> > ls -l $(locate -b -i '\Makefile')
> >
> > poc
> >
> poc:
> 
> Thanks for the additional info.
> 
> I'm unaware of "locate". I have been using "find". Took a quick look on 
> man pages and don't really see a difference, but I am not sure.

They're quite different but overlap to some extent. 'find' is the
reliable way of searching the current system according to a whole bunch
of criteria (man find). 'locate' just does a quick search on a database
which is updated regularly (usually nightly) by the updatedb program.
The difference is that locate is very fast, but of course it only tells
you what existed at the time the database was updated.

You really need both programs at different times.

> The one thing that sticks out is the running in a directory with a file 
> called Makefile:
> +++
> ls -l $(locate -b -i '\Makefile')
> +++
> 
> doesn't give me anything useful, just a 'ls -l' of the directory. The 
> man pages talks about "lists files in databases that match a pattern". 
> What am I missing here?

Nothing. 'locate' is just doing what it's defined to do (man locate). I
gave a quick and dirty example of how to use it, without considering the
case of directories named Makefile since they aren't that usual. You
could modify my example to skip such directories but I doubt it's worth
the effort unless this is something you're going to be doing frequently.

> Plus, I don't see a recursion option, leading me to believe that it 
> wants me to be searching something for all info rather than current pwd?

Again, 'man locate'.

> "find" give me what I want, but not with the protections et al info. 
> Tried to figure out a redirect or pipe to have everything from find go 
> into a "ls -l", but I am either missing the obvious or its more 
> complicated than I am aware of.

find <args> | xargs ls -l

or

ls -l $(find <args>)

poc



More information about the users mailing list