different find commands to use
hi all,
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" many thanks, rob |
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 |
what about if the filename/folder is named something else but it has got spiceworks in the name of the file/folder?
|
Quote:
Code:
find . -name "*spiceworks*" |
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 Code:
find somedirectory -name "*"|xargs grep somestring |
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 ...
|
Better to use "locate" if appropriate - especially if lots of queries are likely.
|
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. |
Quote:
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!" :doh: |
thanks guys
|
does the find command do recursive aswell
|
Quote:
|
Quote:
|
Quote:
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??" :) |
All times are GMT -5. The time now is 03:37 AM. |