![]() $ find $(df -P|awk '$1 ~ /^/dev/ ') -xdev | grep -F -i book1 # Non-GNU based OSes. If you have multiple partitions and you don't know on which one the file is on, you can get a list with lsblk (on Linux-based OSes, parsing df output is an option otherwise) and feed that into find: (root again if you don't know if you can access the file) $ find $(lsblk -O MOUNTPOINT -n | grep -F /) -xdev -iname 'book1*' -print # GNU-based OSes (Errors can be hidden by appending 2> /dev/null at the end of the find command (the comment should be removed)) If you do not include -xdev find searches things on other partitions, like /proc and /sys, which tend to flood your screen with errors, especially if you are not root. $ find / -xdev -print | grep -F -i /book1 # if iname is not available If you have a single partition: (run as root if your user might not have access to the file) $ find / -xdev -iname 'book1*' -print # If the iname extension to find is available It tend to be much slower, but also much more precise. If locate is not available, you can use find instead. If file is on the system for more than a day it should already be in the index and this can be skipped # updatedb # run as root, possibly using sudo, e.g. Locate and its variants tend to be a fast method. The criteria you can tell find to exit after finding the first matching file: find / -iname 'book1*' -print -quit 2>/dev/null I also suggest putting 2>/dev/null at the end of the line to hideĪll *permission denied* and other errors that will be present if you invoke find as a non-root user: find / -iname 'book1*' 2>/dev/nullĪnd if you're sure that you're looking for a single file, and there is only a single file on your system that match If you don't know the full filename, capitalization and location indeed you should use something like this: find / -iname 'book1*' Looking for is actually in your $HOME directory if you worked on Third, remember about quoting the pattern as said in the otherĪnd last - are you sure that you want to look for the fileĮverywhere on your system? It's possible that the file you're Then don't use -iname but -name, it will be faster: find / -name 'Book1.gnumeric' You're sure the file you're looking for is called Book1.gnumeric Specify -iname book1 it might also find Book1, bOok1 etc. Second, -iname will make find ignore the filename case so if you Or specify the full name: find / -iname 'Book1.gnumeric' String book1 match Book1.gnumeric you either have to add * so it Gist is that in order for find to actually find a file theįilename must match the specified pattern. First, an argument to -iname is a shell pattern. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |