LinuxAnswers DiscussionThis forum is to discuss articles posted to LinuxAnswers.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This thread is to discuss the article titled: Find command
Quote:
Command your box from command-line-interface. This is the power of unix/linux & this is the power of find. -------------------------------------------------------------------------------- Find command is just like driving a car to the destination. If you can read & follow the instructions provided, you are destined to reach at proper address. Location director boardings at signals & landmarks are the inputs/options provided by the users/yourself & finally the roads are the hierarchy/paths to follow to reach the desired destination. For example : I had to reach rahul's home but i dont remember the exact address, but i had some clues like, it was on 94th street & it was a red colour building, further on there were two trees situated infront of his house. That was enough for me & indeed i reached his home.
find / -name foo
find / -name fo*
-name : Pattern could be a exact file name or wildcard * can be used
--------------------------------------------------------------------------------
2. Find file with file name 'FoO'
find / -iname foo
-iname : Same as -name variable but the match is case insensitive.
Same way -lname & -ilname variable works.
-lname : File is a symbolic link whose content matches the pattern specified.
-ilname : Same as -lname variable but the match is case insensitive.
--------------------------------------------------------------------------------
3. Finding all 'conf' files at / or at mentioned path.
find / -name *.conf
--------------------------------------------------------------------------------
4. Backing-up/copying all the conf files found in last example over to a seperate folder.
find / -name *.conf exec cp { } / \;
-exec : Executes command. The string { } replaced by the output of find command.
" \;" needs to be there as it tells the end of arguements provided to -exec variable.
A quick note on this use of -name ... be SURE that there's no files
that match the globbed pattern in the directory you invoke the command
from if you don't wrap the search-string in quotes.
E.g.. if you had the following directories in the local path
Sometimes we need to find the file in server which we do not know where exactly it is located:
Search and list all files from current directory and down for the string ABC:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.