I have been using Ubuntu for abuot 2 weeks and and still frustrated with simple file operations.

I want to find a file called 9.jpg. Every internal command and 3rd party program I have tried, gives me 99.jpg, 999.jpg, "lovepotion number9.jpg" and a zillion other similar ones.

How do you search for an EXACT file name WITHOUT wildcards?

This is only my most recent frustration. I'm obviously missing something basic. good tutorial anywhere?


How do you search for an EXACT file name WITHOUT wildcards?

To search an exact file without wildcard use find command.

  1. Open a terminal by Pressing Ctrl+Alt+T

  2. Type the command and hit Enter

    find / -name 9.jpg

If you want to search in your home folder only, use ~/ instead of / and so on. Replace / with the directory name you want to search in them. If you want to search in current directory and all directories withing it, use ./ in place of /.

  • For getting help on Learning Linux filesystem, see this page
  • Also see this very helpful guide to become familiar with Linux system, especially with Debian and it's derivatives like Ubuntu.
  • It doesn't match the exact name when the file doesn't have an extension, for example, a file name translate, to match exactly the file name, use: sudo find / -name "translate"
    – danilo
    Jun 22 at 17:28
locate /9.jpg

Note the / - without it you'll just find every file ending in 9.jpg. Technically though, it searches for file paths with it as a substring on all of the drives, which includes 9.jpg.png, so this works better with files that have file extensions - a file named log using /log will show you every file in /var/log/.

  • man says "use locate - r \[filename]". both seem to work.
    – phil294
    Mar 13 '16 at 4:57
  • @Blauhirn Are you talking about man locate? Cause mine says to use locate -b '\NAME'.
    – wjandrea
    Mar 29 '18 at 22:04
  • @wjandrea mine does too. I have no idea anymore. Maybe the manual changed
    – phil294
    Mar 29 '18 at 22:54

The search in nautilus (the file manager thingy) is, by design, limited to a simple wildcard-like option. If you need something more sophisticated, you can either go for the GUI or the command line.

GUI: install the package gnome-search-tool, either through the software center or by typing

 sudo apt-get install gnome-search-tool

Run it (it is called "search for files"). Leave the main entry empty, and add a search option called "Name matches regular expression". In the new text field, type ^9.jpg (the ^ at the beginning matches the beginning of a string in a regular expression).

enter image description here

As for command line, the find utility will give you the precise answer:

 find . -name '9.jpg'

Consider this: files "999.jpg" and "9.jpg" in the directory t/:

$ ls t
99.jpg  9.jpg
$ find . -name '9.jpg'
$ find . -name '*9.jpg'

I hope that this is clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.