To find all files which contain a certain string, you can use just grep on its own:
grep -R /path/to/directory "myword"
In the example above, "myword"
is what you're looking for, and /path/to/directory
is the directory you want to search through. -R
tells grep
to run a recursive search (i.e. to start at the path you specified, and go into each subdirectory in there).
EDIT
I've re-read your question and I think you're looking for how to find files that have a certain filename. For this use:
find /path/to/directory -name "*glob*" -print
where /path/to/directory
is where you want to start your search (and find
will also look in the subdirectories) and "*glob*"
is a full or a partial file name that you want to look for. Please note, you can use wildcards (.
and *
for any single and any multiple characters match, respectively) in the glob. As a variation to this, you can use, as proposed by others:
find /path/to/directory -name "*glob*" -exec ls -la {} \;
in the above, what you put after the option -exec
is any UNIX command with paramteres (in this case ls -la
). The {}
will be substituted by the file name find
finds, and the \;
is a termination string.
EDIT 2
Please note, the commands above give you similar results to Spotlight, but they don't use Spotlight at all.
If you'd like to use Spotlight from command line, you can use mdfind
command, which is a command-line interface for Spotlight. Typing mdfind
on its own will give you a quick help for using it with a few examples. man mdfind
will give you a more detailed manual for it.
Essentially mdfind
takes a search string (and optional modifiers) as it's argument and it's the same as you would type in Spotlight's text field when using it in a GUI.
To clear it, just delete the ~/.bash_history
file. If you want to just remove the offending lines you can open ~/.bash_history
in the editor of your choice. For me, this would be
emacs ~/.bash_history
and then going to the beginning of each bad line and pressing control ^+K.
Or your can just fill your .bash_history
with empty.
Run this: (including the >
)
> ~/.bash_history
Best Answer
I think you may like Rob's Terminal History Management. You get matches, then the up and down arrow keys let you browse. Almost forgot, the file you want to edit is now ".bash_profile". Open your home folder and press ⇧⌘. to see it.