[ubuntu-uk] find a file

Jim Kissel jlk at osml.eu
Mon Aug 6 13:31:03 BST 2007

norman wrote:
> < snip >
>> Josh Blacker wrote:
>>> There are the two commands 'find' and 'locate' from the command line.
>>> One is slower because it literally trawls the system to find things,
>>> and the other works from a database that's updated every so often - so
>>> it can miss newer files. (I think find is the faster one, but I could
>>> be wrong) As far as I know, find has many more options than locate (eg
>>> to search from the parent directory to a specified depth) - I remember
>>> reading about it somewhere.
>> find /your/path/to/a/directory -name '*.lck' -print
>> Find trawls the files system but appears to cache when re-run with a 
>> short (hours) time.  I've ever used locate.  It has a db where it 
>> 'locates' files.  BTY, if you are using find on directories that you 
>> don't "own", you may need to sudo find has the errors it produces when 
>> it doesn't have permission to read a directory can overwhelm the actual 
>> output of any search.
> Thanks to all who have had a go at answering my question. However, am I
> to understand that I need to know where I might find the file I am
> seeking before I go looking? If that is the case then it defeats what I
> thought was the idea. What I was looking for was a
> command which would tell the computer to search every folder on my
> system.

sudo find / -name '*.lck' -print
will search all mounted file systems for files that end in .lnk
The single quote characters around *.lck are necessary.  Without them, 
the shell will try to expand *.lck in the current working directory and 
then use that in the context of find.

Someone suggested:
find / -name *.lck
try typing ls *.lck to see what arguments are going to be passed to find

sudo "find / -name *.lck" won't work.  You just get
sudo .......: command not found.

Bash: Ubuntu: 7.04
> Norman

Simple effective migration to Open Source based computing

Jim Kissel
Open Source Migrations Limited
w: http://www.osml.eu
e: jim.kissel at osml.eu
p: +44(0) 8703 301044
m: +44(0) 7976 411 679

More information about the ubuntu-uk mailing list