How To Search For Text In Files Mac



How to search for text in files mac download

Preview User Guide

You can open a PDF or other document in Preview, then search for a word or any set of characters. If you can’t see the search field at the top right of the document window, drag the window’s edge (top, bottom, or sides) to enlarge the window.

  1. In the Preview app on your Mac, open a PDF that you want to search.

  2. Type a word or phrase in the search field.

    To find an exact phrase, enclose the phrase in quotation marks.

  3. Do any of the following:

    • Group the search results by page: Choose View > Table of Contents.

    • Sort the search results by number of matches: Click Search Rank.

    • Sort the search results by page number: Click Page Order.

    • Close the search results sidebar: Click Done.

    • Find text in notes: To search notes added to the PDF (instead of the text in the PDF itself), choose View > Highlights and Notes, then type a word or phrase in the search field in the toolbar.

See alsoSelect and copy text in a PDF in Preview on MacBookmark PDF pages in Preview on MacAdd notes and speech bubbles to a PDF in Preview on Mac

Apple forums are full with people asking advices on how to find a lost files that they have been working with for a long time. More often the files were not lost; they just don’t know how to find files on Mac. This tutorial will discuss all possible ways of searching for files on any Mac.

One is to use text clippings. These are snippets of text that look like files, but can’t be edited and behave differently. To create a text clipping, select text in any document and drag it to the desktop. You can then drag it onto any document in any application that accepts text and drop it at the point where you want to paste it. Search for a file by location. In the left-hand sidebar in your Finder, you'll see a list of locations on your computer where files are saved. Click on any of these icons to search by that location. Click 'All My Files' to see all of the files on your computer in the same view.

  • Therefore, you can quickly learn how to find lost files on Mac with this approach. Just go to the Apple logo on the top left corner of the screen and click on the 'Recent Items' option. This will give you a list of the recently accessed folders, apps, and documents. Just click on the icon of your choice to view the file or application.
  • Mac Snow Leopard makes it easy for you to create and edit your text files, such as word-processing files. Text files let you create and format documents that include text and photos and even embed music and video files for Web pages you build. Virtually every computer ever built can read and write in standard.

There are 4 applications that you can use to find a file on Mac:

ApplicationMethod
Spotlight SearchHit Command-Spacebar and type the filename
FinderHit Command-F and type filename in Search Bar
Terminaltype sudo find / -name filename
SiriSay “Find document ” and the name of the doc

Searching with Spotlight Search

Spotlight Search provides the easiest way of searching for files and folders. Just press Command key and while holding it hit the Spacebar button. This will bring up a Spotlight Search bar.

In this bar, you can type the name of the application if you need to launch one or the name of the lost file. After you type in the name of the file and hit Enter the Spotlight Search will display for any file which matches the text pattern you entered in the search bar.

As you can see on the screenshot below the results window consists of two parts: a list of files found on the left side and a preview pane on the right. You can use Up and Down buttons to move between the files and see the contents in the preview.

If you double tap on the file in search results the file will be opened in the default application. In this case, the default application is the Preview app (as indicated by the Preview icon in the top right of Spotlight Search bar).

If instead of opening in the app you need to locate the folder where the file is then to press the Control button and double tap on the file name.

Additionally, the left pane of the Spotlight search results contains suggested web sites and most importantly “Show all in Finder…” link at the bottom.

If you double tap on this link, then files that were found will appear in a new Finder window.

The Finder search results do not show the parent folder of the file, but it is easy to find the one. Right click on the file name and tap on “Show in Enclosing Folder” option in the context menu (the menu that pops up on right click). If you don’t know how to right click on MacBook trackpad read this simple tutorial.

Searching with the Finder app

Finder provides much more flexibility when it comes to searching files and folders. For instance, if you need to open the Downloads, iCloud, AirDrop, Documents or Library folder you can do it from Finder menu under Go menu item.

To find a file start the Finder app (you can do it by typing Finder in the Spotlight Search). Inside the Finder window hit Command-F and it will open the same window that we’ve seen previously.

Start the search by typing the file name inside the Search bar. The Finder will try to immediately the part of the name typed in the bar and more you type more accurate the search results will be. Notice that by default Finder is searching for files where the name matches the word that was typed in.

In this case, “matches” means that it will look for files where the name contains the search phrase. For instance, if you search for “big” the Finder will display “bigfish”, “abigfish” and “gobig”. It does not matter where in the file name the search phrase appears.

Files

But what if we need only the files that start with word “big”? In this case, click on a dropdown under “Search: This Mac” line, change it from “Kind” to “Name”, and change “matches” to “begins with”.

Search capabilities of the Finder app are extremely powerful. Let’s review some use cases.

How to find large files

If you’ve been using the MacBook for a long time chances are that it accumulated a lot of unnecessary files. And some of the files could be big and may prevent you from downloading new apps or uploading new photos.

If you need to clean some space on the Mac, the first thing you need is to find the largest files and delete those that you don’t need.

To find the large files first you need to establish what large means. Let’s assume that the large file is 10MB. In order to find files bigger than 10MB start the Finder, hit Command-F. In the Search area expand the dropdown that contains Kind, Name, and other attributes. Click on “Other…” option.

In the new window type “size” in the Search bar and find “File Size” attribute. Check the box under “In Menu” column on “File Size” line. This will add “File Size” to the list of search attributes.

Now choose “File Size” attribute, select “is greater than”, type 10, and finally select “MB” like this:

The Finder will find every file larger than 10MB on your computer.

Find recently modified files

Same technique as when searching for large files, but now change the search attribute (1st element) to “Last Modified Date”. If the attribute is not available to add it by clicking on the “Other” option.

Any date attribute can be limited to the exact date or interval. The Finder conveniently provides some quick dates such yesterday, today, this week, month, year, etc.

Find specific documents

Another useful search attribute is Kind. If you remember that you were working with the Word document, but don’t remember the name of the document then set search attribute to Kind, then select Other, and in the next textbox type “docx”.

As always, there are some shortcuts for most known apps, so you can choose the type of the document, e.g. PDF or Text or Movie.

Find folders

Another supported Kind attribute is Folder. If you need to find folders in the Finder all you need to set the search attribute to type “Kind” and then select “Folder” as a search attribute value.

Searching with Siri

The most exciting way to search is using Siri which was added not long time ago to macOS.

To start Siri for the first time, you need to type “Siri” in Spotlight Search. If Siri was not enabled on your Mac, it will ask your permission to enable. Once started Siri icon will appear in the top menu bar from which you can always summon it by clicking on the icon.

To find the document say “Find document ” and the name of the file. You can always spell the name of the file if needed.

You can even start searching and then keep narrowing the search results. For instance, you can start with “Find files from the last week”.

When Siri displays results narrow the list down by saying “Just ones from Friday”, and narrow even further more by saying “Just Word documents” and the final list will include only Word documents from last Friday.

Searching with Terminal

Finally, geeks can always use the Terminal app to perform the queries in the command line. To find a file that contains the word “touch” start the Terminal app and type following:

sudo find / -name touch

then enter the administrator password.

sudo command will elevate your privileges and require entering the admin password. Of course, you can skip sudo part and type the command starting with find keyword, but if you do this the find command will constantly pop up questions such “Terminal.app want to access Photos. Allow?”.

Other parameters in the Terminal command:

  • slash (/) is to tell the path to search in. Just slash means search everywhere, but you can limit to a certain folder if you want.
  • -name the search phrase included in the filename.

As you can see yourself, the Terminal app is not a particular user-friendly way to search for files. Spotlight Search and Finder are much better options.

Advanced search tips and tricks with Finder app

Siri is not the only application that allows narrowing search results. If you need to find any Word document which contains the phrase “tricks” and was modified in the last 3 months, then you need to make a multiple condition search criteria. And it is really easy to do.

First, start with the basic search. Set the search attribute type to “Kind”, set the first parameter value to “Other” and second parameter to “docx”.

Second, click on the plus icon in the right corner of the search bar line. Enter the second search criteria: set the search attribute to “Name”, first parameter to “contains” and the second parameter to “tricks”.

And finally, click on the plus icon again to enter the third search criteria where the search attribute is “Last modified date”, the first parameter is “within last” and second parameter is 90.

The rule with multiple search conditions is that they filter documents that satisfy ALL search conditions. If you don’t need one of the conditions you can remove them by clicking the minus icon.

But what if I need to find documents of multiple types?

For instance, if I need to find any PDF or docx file which contains 2018? If I only use plus when adding search conditions, then Finder will find 0 documents because we are asking to find documents that contain phrase 2018 and at the same time of kind PDF AND docx.

Obviously, a file cannot be both PDF and docx.

The trick in building this type of search is to use Alt (Option) key when adding a new condition.

First, start with the basic search. Set the search attribute type to “Name”, select the first parameter to “contains” and second parameter to “2018”.

Now hold the Alt (Option) key. The plus icon will change to an icon with three dots. Click on this icon. It will add two lines. The first line is the aggregate rule. You can choose Any (OR), All (AND) or None (NOT) conditions. Leave it to All. In the second line set to search all PDF files and click on the plus icon at the right corner.

In the new line add a search for docx files. The new search query can be read as “Find all documents that contain 2018 AND (document kind is PDF OR document kind is docx)”.

How To Search For Text In Files Mac Osx

Similarly, you can use None in the query to eliminate some conditions.

Smart folders (Save repeated searches)

After spending so much time crafting the search query you most likely want to save your work. The good thing that Mac allows you to do just that. Just click on the Save button at the top right corner.

The Finder will open a window where you can name your search and define if you want it to appear in the Finder sidebar. After you finish, the search will be saved as a so-called Smart Folder.

As we already know smart folder is not a real folder, but rather a saved search condition. The cool thing is that if you create a file which satisfies the search criteria of the smart folder the new file will automatically appear in the smart folder.

This way you can organize all your files so you can always find all you need in less than a second.

Advanced search with Spotlight Search

How To Search For Text In Files Mac Os

Spotlight Search can do the same things as the Finder as well. The trick is to know its syntax. For instance, if you want to find all PDF documents with Spotlight Search you can type following in the bar:
kind:PDF

Searching for PDF documents which contain word 2018? Type:
kind:pdf and name:2018

Basically, from the Spotlight Search, you can build almost any query condition like in Finder. The problem is that you need to know and remember the keywords used in the tool. This makes, in my opinion, Finder a much easier tool to find the files.

How to find duplicate files

There are many third-party applications that can help you to find and delete duplicate files. Among them are dupeGuru, Duplicate File Finder Remover from Nektony and Gemini 2: The Duplicate Finder from MacPaw. All three are free.

In case if you don’t want to install another app on your MacBook you can find and delete duplicates yourself with Finder.

Steps to follow:

  • Open Finder
  • In the Finder go to File -> New Smart Folder
  • Click on the plus icon
  • Select Kind as search criteria and choose a type of file to find
  • In search results click on Name column to sort by name
  • Scroll down and whenever you find duplicates right click and move to Trash

Common issues with search in Finder

Search For Text In Files Command Prompt

If you can’t find files, make sure that “This Mac” is selected in the “Search” area. If this was changed accidentally to, say, Desktop then Finder will limit search results to Desktop only.

Search For Text In Files Cmd

Topics: