I am trying to find a hidden file that I know the name, but no the location of.
The name is "message", and I have tried sudo locate *message*, but I have not found it. I have too much output, plus I do not think locate is showing the hidden files. Any ideas?
Asked
Active
Viewed 1.6k times
5
Gavin Morton
- 87
- 1
- 1
- 11
-
5`ls -la` (-a shows all files [inc. hidden], l is just for long) ... to find a known.filename, `find / -name wantedfile` – guiverc Dec 02 '17 at 01:21
-
If the name of the file is "message", then it is not hidden. Hidden files have a dot at the start, i.e. ".message". Do you mean that the filename *contains* "message"? – wjandrea Dec 02 '17 at 01:34
-
When you say you haven't found it, what do you mean? Did `locate` not find it? Did `locate` give you too much output to go through? – wjandrea Dec 02 '17 at 01:45
-
What happens if you run `sudo find / -name "*message*"` and wait for it to finish? There will be less output if you remove the wild-cards, `sudo find / -name "message"` which will find the file, if you are sure that the name is message. – sudodus Dec 02 '17 at 06:03
-
1The proper way to call `locate` is (with quotes!) `locate "*message*"`. By the way, `locate message` (with no wildcards, and hence no quotes) is enough. Now if `locate` can't find it, it could be because that file is too recent to be in the database. In this case, updating the database with the command `sudo updatedb` will help (this command will take some time). – gniourf_gniourf Dec 02 '17 at 12:34
-
Are you sure you need quotes to call `locate`? I just use the asterisk and it seems to work. – Gavin Morton Dec 08 '17 at 22:35
-
The question referred specifically to the `locate` command. There is a difference in the commands: `locate` can be significantly faster than `find`, so is there a way to `locate` hidden files? – iND May 28 '20 at 17:14
1 Answers
6
Try this:
sudo find / -name ".message"
I'm assuming the locate command gave you too much info to go through, so this should be a bit more succinct, where it only matches the filename, not the path.
wjandrea
- 14,109
- 4
- 48
- 98
-
p.s. I wrote a comment under your question to ask for clarification. This answer may change based on your reply. – wjandrea Dec 02 '17 at 01:42
-
-
I think it depends what you mean by hidden. The linux way to hide a file is to let its name start with a dot. (It means that some tools will not see it, for example `ls` (unless you use the option `-a`). Please explain what *you* mean by 'hidden'. – sudodus Dec 05 '17 at 14:46
-
When I say hidden, I am quoting a readme for a practice image for the CyberPatriot competition. The last time the readme said hidden, it was a filename with a dot in it, so I would assume the same for this one. – Gavin Morton Dec 05 '17 at 14:50
-
The question referred specifically to the `locate` command. There is a difference in the commands: `locate` can be significantly faster than `find`, so is there a way to `locate` hidden files? – iND May 28 '20 at 17:12
-
@iND This question was vague, hence why the answers and comments are messy. Please ask a new question, and include what you've already tried. Send me a link and I'll try answering it myself. – wjandrea May 28 '20 at 17:47