Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does this command do? find . -name cgi-bin -exec ls -la {} \; 3

Status
Not open for further replies.

farley99

MIS
Feb 12, 2003
413
US
find . -name cgi-bin -exec ls -la {} \;
 
Searches from where the command is issued, down the directory tree and displays an ls -la of all files foiund called cgi-bin. It might be an idea to enclose the cgi-bin in single quotes to obviate any problem with the hyphen. HTH.
 
farley99

It will 'execute' the command following it, which in this case is an ls -la

Cheers!

 
The 'find' command is a very powerful command that searches entire directory trees for files meeting certain criteria. It can search on name, size, modification date, contents, etc. Type 'man find' for more info.

The . is the starting point. A single dot in Linux means the current directory.

The '-name' means to search based on name, as opposed to all the other criteria that can be searched.

The 'cgi-bin' is a parameter to the '-name' criteria. That is the name being looked for. You can use wildcards as well, as long as you include the entire parameter in quotes, such as: find . -name '*.cgi'

Normally, 'find' will simply print a name of matching filesor directories. But if you include the '-exec', it means to execute the following command for each file found instead.

Everything after '-exec' is the command to be executed, where the '{}' curly braces will be replaced by the name of each file.
 
$ locate cgi-bin
does much the same job, in a fraction of the time because it uses the locatedb database rather than slooowly searching thru every single directory.
Try it.
 
yes locate is very fast ... if the file's path is already stored in locatedb.
If you are trying to locate a "new" file this db isn't updated and there is no result even if the file is there.
I guess the update is run once a day, but you can force the update with the updatedb command.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top