Search Command For Mac



There's a quick and easy keyboard shortcut you can use to search for words on your Mac. This command — Command + F — lets you search for words in everything from documents to web pages. Alternatively, you can use the search bar in Preview to search through text-based documents on your Mac. Visit Business Insider's homepage for more stories. The Mac OS X Snow Leopard Finder helps you access and organize most of the important Mac functions while you work. Use Finder keyboard shortcuts to display windows, copy and move files, and launch applications. These keyboard shortcuts help you get things done more efficiently. Key Function Command+A Selects all items in the active window. This can be used to get mac address for remote computers also. Below are few examples on how to use this command. It works on XP, Vista, Windows 7, Server 2003 and Server 2008 operating systems. Get mac addresses from CMD. Just run the command getmac to get the mac addresses. Find an example below.

  1. Search Command Mac Terminal
  2. Command For Mac Terminal

Is Spotlight broken? Can't find the app, document, or photo you want using Spotlight on your Mac? You can fix it in 5 seconds using Terminal.

If you're using Spotlight on Mac (Command + Spacebar) to quickly open an app, document, or photo—and it doesn't work—you may need to re-index Spotlight. Use this guide to fix Spotlight using Terminal on your Mac (plus a pro Spotlight tip). The solution works on any macOS version (tested on macOS High Sierra).

How to Fix Spotlight Search on macOS High Sierra with Terminal

Terminal is another way to control your Mac, and if you've never used it before, don't worry, this is a safe command to run (even if you have no idea what you're doing).

  1. Open the Terminal app from your 'Applications' folder

  2. Open the 'Utilities' folder and launch 'Terminal'

  3. Copy and paste this command and press enter:

    1. The -E command will 'Erase and rebuild index'—which is exactly what you want to do to fix the problem. / means to start at your hard drives root directory, which will make it re-index everything on your hard drive.

    2. Other guides might have you try to delete the Spotlight files, which I think is unnecessary, and a huge risk if you're new to the command line tools (i.e.: Terminal).

    Warning: Do not type any command with the rm keyword (remove) and -rf options (recursive force: i.e.: no confirmation . . . goodbye files!), unless you know what you're doing. You can accidentally delete your entire hard drive, as this command is not safe!

  4. Type your password, and let it run. Give your Mac 15-30 seconds to start re-indexing all your files, apps, and images.

  5. Try searching for 'Safari' with Spotlight (Command + Spacebar).

Search Command For Mac

Note: You may have to wait longer your entire hard drive (and all the files) to be indexed, but apps should be indexed pretty quickly.

Symptoms of a Corrupt Spotlight on Mac

Command to search for words mac

The telltale sign of a corrupt Spotlight is when you try to search for an app you use frequently using Spotlight, and it's not the first result (it might not even be in the list!).

Numerous times I'll try to open an app like TextMate, Evernote, or even Terminal, and the search results only show web pages, documents, and no apps.

Since I use my keyboard to launch apps quickly, this is a huge decrease in my productivity. The workaround is to use the Applications folder, or Launchpad to find the app I want to use.

Why Does Spotlight Search Break?

Spotlight will sometimes fail due to bugs in the macOS. On the initial launch of If you're experiencing this frequently, you should submit a bug to Apple at bugreport.apple.com.

Explain what happened, and they will follow up with you, and the bug will get fixed, rather than never getting fixed!

I submitted a bug #31646293, 'Spotlight loses index for apps that are updated from App Store,' on April 15th 2017, and Apple fixed it on July 11th 2017 (duplicate of bug #24109163).

I worked at Apple in the past, and they do read your bug reports, and they do fix issues when they know the problem exists.

Pro Spotlight Tip: Type Less

You can change the default search result if you start typing the first few letters, and then select the option you want with the arrow keys (or the mouse).

The next time you start typing 'Terminal' stop with the first three letters: 'Ter'. Try it:

  1. Open Spotlight from the top right corner icon (Command + Spacebar)
  2. Start typing 'Ter' (add more letters if you don't see Terminal in the list)
  3. Select Terminal

Now you've 're-trained' Spotlight for showing Terminal as the first result for 'Ter'.

References

Follow Me

Let me know if this was helpful in the comments below, or follow me on Twitter @PaulSolt

If the weird name throws you, 'grep' is an acronym for 'general regular expression
program'. If that doesn't help, it's probably because you're wondering what a
regular expression ('re' or 'regex') is. Basically, it's a pattern used to describe
a string of characters, and if you want to know aaaaaaall about them, I highly
recommend reading Mastering Regular Expressions by Jeffrey Friedl and
published by Unix über-publisher O'Reilly & Associates. Search command line mac

Regexes (regices, regexen, ...the pluralization is a matter of debate) are an extremely
useful tool for any kind of text processing. Searching for patterns with grep is
most people's first exposure to them, as like the article says, you can use them to search
for a literal pattern within any number of text files on your computer. The cool thing is
that it doesn't have to be a literal pattern, but can be as complex as you'd like.

The key to this is understanding that certain characters are 'metacharacters', which have
special meaning for the regex-using program. For example, a plus character (+) tells the
program to match one or more instances of whatever immediately precedes it, while parentheses
serve to treat whatever is contained as a unit. Thus, 'ha+' matches 'ha', but it also matches
'haa' and 'haaaaaaaaaaa', but not 'hahaha'. If you want to match the word 'ha', you can use
'(ha)+' to match one or more instances of it, such as 'hahaha' and 'hahahahahahahahaha'.
Using a vertical bar allows alternate matching, so '(ha|ho)+' matches 'hohoho', 'hahaha', and
'hahohahohohohaha'. Etc.

There are many of these metacharacters to keep in mind. Inside brackets ([]), a carat (^)
means that you don't want to match whatever follows inside the brackets. For Magritte
fans, '[^(a cigar)]' matches any text that is not 'a cigar'. The rest of the time, the carat tells
the program to match only at the beginning of a line, while a dollar sign ($) matches only at
the end. Therefore, '^everything$' matches the word 'everything' only when it is on a line all
by itself and '^[^(anything else)]' matches all lines that do not begin with 'anything else'.

The period (.) matches any character at all, and the asterisk (*) matches zero or more times.
Compare this to the plus, which matches one or more times -- a subtle but important
difference. A lot of regular expressions look for '.*', which is zero or more of anything
(that is, anything at all). This is useful when searching for two things that might or might
not have anything else (that you probably don't care about) between them: 'foo.*bar' will match
on 'foobar', 'foo bar' & 'foo boo a wop bop a lop bam boo bar'. Changing the previous example
to a plus, 'foo.+bar', requires that anything -- come between foo and bar, but it doesn't matter
what, so 'foobar' doesn't match but the other two examples given do match.

For details, try the man pages -- 'man grep'. There are a lot of different versions of the
program, so details may vary. All of this should be valid for OSX though.

Confusing? Maybe, but regular expressions aren't that bad when you get used to them, and
they can be a very useful tool to take advantage of it you know what you're doing. An example.

Let's say you have an website stored on your computer as a series of html documents.
As a cutting edge developer, you've seen the CSS light and want to delete all the
tags wherever they're just saying e.g. face='sans-serif' &/or size='12', because the
stylesheet can now do that for you. On the other hand, it's possible that the patterns
'face='sans-serif' or 'size='12' could show up in normal text (though admittedly
that's unlikely). In fact, what you really want to know is wherever those patterns show up in
a font tag, but you don't care about anywhere else that they might appear. Here's one way to
find that pattern:

This does a number of things. The -i tells grep to ignore case (otherwise it's case sensitive,
and won't match 'FONT' if you're looking for 'font' or 'Font'). The -r tells it to recursively
descend through the directories from wherever the command starts -- in this case, all htm and
html files in the current directory. Everything in single quotes is the pattern we're matching.
We tell grep to match on any text that starts with ' (thus staying within the font tag), and then either the face or
size definition that we're interested in. The one glitch here is that line breaks can break
things, though there are various ways around that. Finding them is left as the proverbial
exercise for the reader. :)

The next question is, what do you want to do with this information you've come up with?
Presumably you want to edit those files in order to fix them, right? With that in mind, maybe
it would be useful to just make a list of matches. Grep normally outputs all the lines that
match the pattern, but if you just want the filenames, use the -l switch. If you want to save
the results into a file, redirect the output of the command accordingly. With those changes,
we now have:

Great. But we can do better still. If you are comforable with the vi editor, you can call vi
with that command directly. The trick is to wrap the command in backticks (`). This is a cool
little Unix trick that runs the contained command & returns the result for whatever you want
to do with it. Thus you can simply put this command:

The result of this command, as far as your tcsh shell is concerned, is something along the lines
of

Search Command Mac Terminal

etc. The beautiful thing here is that if you quit vi & re-run the command later, it will be
able to effectively 'pick up where you left off', since files you've already edited will
presumably no longer match the grep command.

Command For Mac Terminal

And if you want to get really ambitious, you can use these techniques in ways that
allow you to do all your editing directly from the command line, without having to go into an
interactive editor such as vi or emacs or whatever. If you make it this far in your experiments,
then the next step is to learn to filter the results of a match and process the filtered data
in some way, using tools such as sed, awk, and perl. Using these tools, you can find all
instances of the pattern in question, break it down however you like, substitute or shuffle the
parts around however you like, and then build it all back up again. This is fun stuff! By this
point, you're getting pretty heavily into Unix arcana, and the best book that I've seen about
these tricks is O'Reilly's Unix Power Tools, by various authors. If you really want to leverage
the power of the tools that all Unixes come with, including OSX, then this is a great place to
both start & end up. There's plenty of material in there to keep you busy for months & years...