Let's say there a file called "abc_deh.xyz", what command do i use to find the location of that file in mac terminal by using solely the search term "deh"? So, basically, I am asking how to search for a file by text contained in its name. I need to find files that I forgot the whole name, that would be more helpful.
sudo find / -type f -name "*deh*"
if you want to search directories too then remove the -type f. You can also try: sudo locate deh
Should your locate database not be created (or up to date), there is a chance you have that file on the filesystem, but it's not been stored yet. Rather than run a single find command above, building the locate.db database might be a better plan going forward.
glob-complete-word a lot:
open */*deh # press \eg to complete paths
set show-all-if-ambiguous on to
~/.inputrc if you haven't already. If there are multiple completions, it makes the first press of
\eg show all of them. If it's not enabled and there are multiple paths that match
*deh part is deleted.
If you use bash 4,
shopt -s globstar makes
** match multiple levels of directories.
If you use mdfind or find and there is a single line of output, you can use a key binding like this to insert it: