CentOSThis forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.
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.
im taking charge of all the companys archive/restore jobs for data backups on LTO tapes and sometimes people dont know the location of the file(s)/folder(s)
i know you can use the find command for this but i want to know a few commands to find certain keywords, like if the file or folder has any words or letters like "spiceworks"
There are a lot of different kinds of ways to use find
The find man page is a excellent resource
Code:
man find
Code:
NAME
find - search for files in a directory hierarchy
SYNOPSIS
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...]
[expression]
DESCRIPTION
This manual page documents the GNU version of find. GNU find searches
the directory tree rooted at each given starting-point by evaluating
the given expression from left to right, according to the rules of
precedence (see section OPERATORS), until the outcome is known (the
left hand side is false for and operations, true for or), at which
point find moves on to the next file name. If no starting-point is
specified, `.' is assumed.
If you are using find in an environment where security is important
(for example if you are using it to search directories that are
writable by other users), you should read the "Security Considerations"
chapter of the findutils documentation, which is called Finding Files
and comes with findutils. That document also includes a lot more
detail and discussion than this manual page, so you may find it a more
useful source of information.
...
If the string you want is part of the filename, you can use wildcards with find, providing you enclose the string in quotes. Or you can use locate, which automatically picks up substrings unless you tell it not to.
To find a file with a particular string in the text, use find and pipe the result through xargs grep. For example
I'll just recommend using single quotes instead of double there. This ensures the wildcard pattern is interpolated by the find cmd, rather than the shell - this makes a difference ...
i don't like locate.
i always have the feeling it wants me to believe that it's making a realtime search, but in reality it only accesses a database that was created... when? last time updatedb ran?
and when updatedb runs, it takes lots of resources, usually at a time when i don't have the patience for it.
no, better use find, and learn to use it properly.
or consult packet management about installed files.
An environment with multiple users and using LTO tapes ain't your typical home user. They are probably running updatedb in the wee hours every night. So yes the database may be "out of date" for todays files. Easy (and cheap resource-wise) to rectify.
"find" works as we all know, but locate has it's place. I find I have to rerun the updatedb about once a week - takes little time these days.
ok, i guess my previous post was opinionated.
but it stands, esp. because i've seen (more than once) forum posts like: "why don't you use locate? it's much faster than find!"
Actually it is recursive unless you tell it not to be so (-maxdepth 1). For the OP: this also means you can limit the depth of recursion.
Good point, and you're exactly right.
To the OP, though, related to your original post...what are you using currently to take your backups? It could be that the software itself maintains a database as to what's written, that you could query via SQL (like Tivoli Storage Manager, for example), and see file names/locations.
And it always has entertained me over the years that end-users can't tell you where the file is, or what it's called...but somehow 'know' they need it restored. The follow-up questions are similarly entertaining..."Well, since you don't know what drive you saved it to, what the file name is...what program did you use to create it?", "I used MICROSOFT...that's all I know", ".......".
I asked someone one time "Since you don't know where it was, or what it was named, then how do you know it's missing??"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.