How to find a file on a windows computer. Advanced search in Windows or how to find a file in Windows? Find the file that contains

Sometimes you may need to find a file that contains a certain string or find a line in a file that contains a specific word. In Linux, all this is done using one very simple, but at the same time powerful utility. grep. With its help, you can search not only for lines in files, but also filter the output of commands, and much more.

In this manual, we will look at how to search for text in Linux files and look at the possible options in detail. grep, and also give several examples of working with this utility.

Team grep(stands for global regular expression print) is one of the most popular commands in the Linux terminal, which is part of the GNU project. The secret to its popularity is its power; it allows users to sort and filter text based on complex rules.

The grep utility solves many problems, it is mainly used to find strings that match a line in text or the contents of files. It can also find by pattern or regular expressions. In a matter of seconds, the command will find a file with the required line, text in the file, or filter only a couple of required lines from the output. Now let's look at how to use it.

grep syntax

The command syntax is as follows:

$ grep [options] pattern [filename...]

$ command | grep [options] pattern

  • Options- these are additional parameters with which you specify various search and output settings, such as the number of lines or inversion mode.
  • Sample- this is any string or regular expression that will be searched
  • File and command - this is the place where the search will be conducted. As you will see further, grep allows you to search multiple files and even a directory using recursive mode.

The ability to filter standard output is useful, for example, when you need to select only errors from the logs or find the PID of a process in a numerous utility report ps.

Options

Let's look at the most basic utility options that will help you search for text in files more efficiently grep:

  • -b- show the block number before the line;
  • -c- count the number of occurrences of the pattern;
  • -h- do not display the file name in search results inside Linux files;
  • -i- ignore case;
  • - l- display only the names of files in which the template is found;
  • -n- show the line number in the file;
  • -s- do not show error messages;
  • -v- invert the search, return all lines except those containing a pattern;
  • -w- search for a pattern as a word surrounded by spaces;
  • -e- use regular expressions when searching;
  • -An- show the occurrence and n lines before it;
  • -Bn- show the entry and n lines after it;
  • -Cn- show n lines before and after the entry;

We've covered all the most basic options and even more, now let's move on to examples of the command's work grep Linux.

Examples of using

The theory is over, now let's move on to practice. Let's look at some basic examples of searching inside Linux files using grep, which you may need in everyday life.

Finding text in files

In the first example, we will look for the user User in the Linux password file. To search for text grep In the /etc/passwd file, enter the following command:

grep User /etc/passwd

As a result, you will get something like this, assuming such a user exists, of course:

User:x:1000:1000:User,:/home/User:/bin/bash

Now let's not take case into account during the search. Then the combinations ABC, abc and Abc from the point of view of the program will be the same:

grep -i "user" /etc/passwd

Print multiple lines

For example, we want to select all errors from a log file, but we know that the next line after the error may contain useful information, then we will use grep to display several lines. We will look for errors in Xorg.log using the “EE” pattern:

grep -A4 "EE" /var/log/xorg.0.log

Will output the line with the occurrence and 4 lines after it:

grep -B4 "EE" /var/log/xorg.0.log

Prints the target line and 4 lines before it:

grep -C2 "EE" /var/log/xorg.0.log

Will output two lines from the top and bottom of the entry.

Regular expressions in grep

Regular Expressions grep- a very powerful tool that greatly expands the possibilities of searching for text in files. To activate this mode, use the option -e. Let's look at a few examples:

Search for an occurrence at the beginning of a line using the special character "^", for example, we will display all messages for November:

grep "^Nov 10" messages.1

Nov 10 01:12:55 gs123 ntpd: time reset +0.177479 s
Nov 10 01:17:17 gs123 ntpd: synchronized to LOCAL(0), stratum 10

Search at the end of the line - special character "$":

grep "terminating.$" messages

Jul 12 17:01:09 cloneme kernel: Kernel log daemon terminating.
Oct 28 06:29:54 cloneme kernel: Kernel log daemon terminating.

Let's find all lines that contain numbers:

grep "" /var/log/Xorg.0.log

In general, regular expressions grep- This is a very broad topic, in this article I just showed a few examples. As you have seen, searching for text in grep files becomes even more efficient. But a full explanation of this topic would require an entire article, so let’s skip it for now and move on.

Recursive use of grep

If you need to search for text in multiple files located in the same directory or subdirectories, for example in the Apache configuration files - /etc/apache2/, use a recursive search. To enable recursive search in grep there is an option -r. The following command will search text in Linux files in all subdirectories of /etc/apache2 for the string mydomain.com:

grep -r "mydomain.com" /etc/apache2/

In the output you will get:

grep -r "zendsite" /etc/apache2/
/etc/apache2/vhosts.d/zendsite_vhost.conf: ServerName zendsite.localhost
/etc/apache2/vhosts.d/zendsite_vhost.conf: DocumentRoot /var/www/localhost/htdocs/zendsite
/etc/apache2/vhosts.d/zendsite_vhost.conf:

Here, the found string is preceded by the name of the file in which it was found. It is easy to disable the file name output using the option -h:

grep -h -r "zendsite" /etc/apache2/

ServerName zendsite.localhost
DocumentRoot /var/www/localhost/htdocs/zendsite

Finding words in grep

When you are looking for the string abc, grep will also output kbabc, abc123, aafrabc32 and similar combinations. You can force the utility to search the contents of files in Linux only for those lines that exclude the search words using the option -w:

grep -w "abc" filename

Search two words

You can search the contents of a file not for one word, but two at once:

egrep -w "word1|word2" /path/to/file

Number of occurrences of a string

Utility grep can tell you how many times a particular string was found in each file. To do this, use the option -c(counter):

grep -c "word" /path/to/file

Using the option -n You can display the line number in which the occurrence was found, for example:

grep -n "root" /etc/passwd

1:root:x:0:0:root:/root:/bin/bash

Inverted search in grep

Team grep Linux can be used to find lines in a file that do not contain a specified word. For example, print only those lines that do not contain the word pair:

grep -v steam /path/to/file

File name output

You can specify grep display only the name of the file in which the specified word was found using the option -l. For example, the following command will display all file names whose contents were searched to find an occurrence of primary:

grep -l "primary" *.c

Color output in grep

You can also force the program to highlight occurrences in the output with a different color:

grep --color root /etc/passwd

It will turn out:

conclusions

That's all. We looked at using the command grep to search and filter command output in the Linux operating system. When used correctly, this utility will become a powerful tool in your hands. If you have any questions, write in the comments!

Over a long period of time working with a computer, a huge number of files and documents accumulate on it. To avoid cluttering the desktop, files are transferred to other storage locations. As a result, a huge number of folders and subfolders appear and it becomes increasingly difficult to find the desired file. After all, it’s difficult to remember exactly which “new folder” it is in. Fortunately, Windows has a convenient search system built into it that will help you find a file on your computer, even if you don’t remember its exact name.

If you can’t find the file you need, the first thing you should do is look at the “Trash” system folder on your desktop. Suddenly you accidentally deleted it, and because of this you cannot find it in its usual place. It’s better to check right away so that you don’t later clear all the files, permanently deleting the information. Although, in fact, information deleted from the recycle bin can be restored using special programs. But this is a completely different topic, so if you are interested, read this article.

To search for files on a computer running Windows XP, do the following:

  1. Give the command “Start - Search”.
  2. Click on "Files and Folders" to launch the Find Files and Folders Wizard.
  3. Select a category, for example "Video". You can select one, several or all categories at once. Click the Find button.

Windows will find all of the above files on any PC disk partitions and external storage devices (including network ones). For example, when you put together all the movies and videos, it's time to use the search, for example, only for video files. It is also worth refining the search in order to quickly find a specific file by entering at least part of its name.

The asterisk character replaces any number of letters and numbers in the file name. For example, instead of the keyword “asterisk” you can enter “sound” - all variants of this word in the name of the searched file will be searched, for example, a file named “No sound.mp3”. Specifying only the file name extension, for example, *.docx, will detect all your Word documents in this format, for example, the file “resume.docx”.

It is also possible to assign a file search on a Windows PC to hidden files and folders.

To find files based on a keyword in a document, do the following:

  1. Give the already familiar command “Start - Search” and in the “Word or phrase in file” column, indicate a keyword, for example, “abstract”.
  2. In the file name, specify the extension, for example, “.doc”.
  3. Also specify the search location, for example, drive C. Check the desired options, for example, search in hidden and system folders, and click the “Find” button.

All documents containing the word “abstract” in DOC file format will be found.

How to find files on a PC with Windows 8/8.1/10/10.1

Having updated the version of Windows to 8 or 10, the user will notice that the search tools are assembled and configured more conveniently than in previous versions of this OS. Although at first it may be inconvenient to use them.

Search files on PC by name

  1. Give the command “This PC – Search” (search tab). In the Windows search box, enter part of the file name (or the whole name, if you remember it). Press "Enter" on your keyboard.
  2. The required file (or files) will be found (or will be found).

Search files by name extension

By remembering the file name extension you were working with, you can search for it by that name. For example, archive files most often have the extension .rar or .zip, program files (including installation packages) - .exe or .msi, etc. As a result, when searching for files by extension, you will most likely discover your loss.

It happens that you do not remember the file extension, because the Windows system does not display any file extensions by default. To enable them, do the following:

  1. Give the command “Start – Control Panel – Folder Options”.
  2. Go to the command “View – Options – Change settings for files and folders”.
  3. Uncheck "Hide extensions for known file types." For more experienced users, the “Hide protected system files” feature may be useful.
  4. Click the “Apply” and “OK” buttons in sequence.

Windows Explorer will restart and display file extensions. Having matched the one you are looking for with the extensions of similar files (by the type of file icon), enter its extension in the already familiar search bar and press the “Enter” key. Windows will find the missing file.

For example, a video clip in AVI format has disappeared. Open the familiar file search panel and enter the file extension .avi. Press Enter and review the files found.

Search files by occupied disk space

Having guessed that, for example, a two-hour movie has a large volume, for example, a video file in UltraHD format (“rip” from a Blu-Ray disc), you can enter, for example, a command to search for files larger than 10 GB.

Windows uses a command format to search for a file by size: “System.Size:>size_in_megabytes”. For example, in this case it will be the command “System.Size:>10240MB”.

With a high degree of probability, this movie will be found, for example, on an external (network) drive.

How to find hidden files

To gain access to hidden files, enable the function to show them.

  1. Go to the familiar Windows Folder Options settings window.
  2. Give the already familiar command to change folder and search settings.
  3. Enable the "Show hidden files, folders and drives" option.
  4. Click the "Apply" and "OK" buttons.

Repeat the search for the file using already familiar attributes: name and/or extension, size, etc.

Search files by keywords

Keywords in the file content (letters, documents, books, etc.) can be specified directly in the File Name field. So, if you are looking for course projects, write “coursework” in the file name.

Windows will display files with the available keywords (or phrases).

Third-party file search programs

The functionality of a file manager is endowed not only with the built-in Windows Explorer. In the past, these were Norton/Volkov Commander, Far File Manager, Total Commander, File Explorer and their analogues.

Searching for files using the Total Commander example

Text documents, regardless of their formatting, are searched by Total Commander by name, size and keywords (or phrases).


Windows will find the files you are looking for.

Finding a file on a Windows PC is not a problem. The main thing is that you do not erase it permanently by using other applications for this purpose. The Windows system already has the necessary tools for searching files, folders and disks, but if for some reason it does not suit you, use a third-party file manager, which may contain additional functions for searching files on disks.

In order to find any object on your computer, just enter the name of the file or folder you need in the Start menu. The computer will search for all files containing this name in whole or in part. But this is not always enough to find all the necessary information on your computer. There are times when you need to find document(s) with certain words in the text, for example: “free computer courses”, but by default in Windows 7 this function is disabled.

Setting up file search in Windows 7

To do this, open “Computer”, click on the “Arrange” button on the left and select “Folder and Search Options”.

After such a small setup, the search will work by file names, as well as by its contents.

Finding files in Windows 7 in practice [check]

Let's check if everything works correctly. To do this, open “Computer”, enter in the search field the word that you need to find in the files. For example, I chose the word “quality”. When you enter a word or phrase, the search will begin automatically (no need to click anything).

After the search completes the task on this word, files containing the word “quality” will appear below. You should also know that after searching for the information you need, you need to change the default settings (which were). This is due to the fact that the search will take much longer, since it searches not only the file name, but also its contents.

For quick search in Windows 7 by content, it is best to go to the folder where your file may be located and search from there.

Almost all users who switched from Windows XP to “Seven” were disappointed by the more meager set of search functions, since, at first glance, the search for programs and files in Windows 7 is not equipped with the usual filters. However, if you know the basic techniques for using the system in order to find the necessary data on the computer, it will not require a significant investment of time and effort, even for novice users. Below are all the main methods on how to quickly find any file or program on a computer with Windows 7.

Using the Start button

You need to do the following:

Note: As you can see from the example above, this same method allows you to find the program, not just the files.

As an example of quickly finding and launching a utility, consider launching the “Console”. You can simply type “cmd” in the same column, and a link to open the “Command Prompt” will appear in the top line.

Using a special search interface "Windows 7"

Of course, the relevance of this method has almost completely disappeared after specialists from Microsoft introduced a search field directly in the start menu, but knowing about its capabilities will be useful for any owner of a computer running a “Seven”.

The following sequential steps are required:


Via Explorer

The algorithm of actions consists of the following stages:


How to configure search parameters

The following steps need to be taken:

Quick search by file type

In the case when the user knows the type of file being searched, you can specify its extension, and only specific types of files will be displayed: images, videos, text, audio, etc.

To perform the operation only among “Word” files, you need to type the extension “*.doc” or “*.docx” in the column. Instead of *, enter characters from the document name. The procedure for Excel is similar, only “*.xls” or “*.xlsx” is used.

Examples for searching images, videos, text and audio files:

*.jpg, *.avi, *.txt, “*.mp3”.

Search by content

“Seven” has a convenient ability to find the file you need based on the text it contains. For example, the user knows that inside the document there are definitely characters printed sequentially and next to each other - “Shovel”.

To identify the location of a file with such a word, you will need to perform the following steps of sequential actions:


Note: the search procedure will now take the user several times longer, so it is recommended to use this filter only when the others do not allow you to obtain a successful result.

Fixing search parameters

Users usually need to use the same search parameters. In Windows 7, there is a convenient option for saving them in order to eliminate the time wasted on re-entering them in the future.

For this purpose, it is enough to specify the necessary parameters once and, having received the result, click “Save conditions”. Next, a menu will be displayed in which you should type the name of the request and click “Save”.

During the next search with similar parameters, the user will only need to enter the “Favorites” section and click on the previously specified name of the request.

When upgrading from Windows Vista, search in Windows 7 it just becomes more convenient and does not contain any special surprises. This cannot be said about many Windows XP users who are just discovering the daily use of the system with such a convenient tool as instant search. Searching in Windows 7 is really very simple. But, as in any search, the goal is to find what you need, and sometimes difficulties arise with this. With this article I begin a story about how search works in Windows 7, how to configure it, how to search, and most importantly, how to find.

How search works

You've most likely heard about an index - a set of files that contain various information about files and documents stored on disk. When you use search, it is the index files that allow you to quickly display results. The index includes various file properties, and this is not just the path, name or size. For example, all tags of MP3 files are indexed - from the author to the bit rate. For office documents, data is indexed, which can be seen in the file properties on the tab Details, document content, and so on. If this search is new to you, I recommend reading a couple of help articles to get some background information on searching. Minimize all windows, click F1 and in the field Search help enter... Search.

Indexing happens constantly - if you add, delete or change a file in a folder, it will immediately be reflected in the index.

The screenshot shows the locations that are indexed by default. Therefore, if you store your documents somewhere in F:\Documents, they will not be included in the index and will not be found by a quick search - they must be added to the index separately. Setting up the search will be discussed below.

Search and indexing settings

To be honest, the standard search settings are quite good, and most users do not need to change anything in them, especially if documents and files are stored in standard folders. To configure settings, open the Start menu and type search options into the search box.

So casually we used one of the search options Windows 7- quick access to control panel elements from the Start menu.

Change search options for files and folders

I will not duplicate the parameters that are clearly visible in the screenshot.

Please note the following points:

    By default, search within a folder searches all subfolders

    in non-indexed locations, only file names are searched and compressed files are ignored

    you can use language search, i.e. compose search queries in a more fluent language - for example, last week's video (there will be a lot of unexpected results mixed in here, especially in localized versions)

Indexing options and Windows Search services

Here you can configure many more settings. To add folders to the index, click Change.

It is no coincidence that the Windows and Program Files folders are excluded from the search - they will greatly increase the size of the index, and will be of little practical use. Programs can already be found by searching in the Start menu - after all, the main menu is indexed by default.

Clicking Additionally, you get access to two groups of settings:

    indexing technical parameters

    indexing options for file types

In the first of them, you can add encrypted files to the index, rebuild the index (which may be necessary in case of problems) and set a new location for it.

For file type (extension) you can:

    include or exclude it from the index

    determine whether only properties or content will be indexed

    add new extension

For example, if your instant messaging client suddenly saves history in text files with a LOG extension, or you just need to analyze logs, their contents will not be indexed by default. But you can easily customize the search - just type log on your keyboard to move through the list of extensions and enable content search.

How to search

When starting a search, it is advisable to immediately imagine whether the search object is included in the index. As I said above, the index covers the user's profile - libraries, files, etc. Here you can find the files you need relatively easily.

But if you open the main search window and expect to find something in the Program Files or Windows folder, you may generally get the impression that “the search finds nothing” because only the results from the index are displayed. We'll talk about searching in non-indexed places later, but now we'll look at general search methods in Windows 7. You can search:

    from the Start menu

    in the main search window

    in libraries

    in other Explorer windows - folders, "Open" and "Save As" dialogs

Search in the Start menu

When you search from the Start menu, the search results show not only files and documents, but also programs and Control Panel items. Now you can safely give up the Windows XP habit of carefully sorting applications in the menu Programs. It is enough to enter the first few letters of the program name to find it. This is much more convenient, especially if you have many programs installed.

Advice. If you use portable applications, simply add their shortcuts to the %appdata%\Microsoft\Windows\Start Menu\Programs folder (you can create a subfolder for them). They will appear in a group in search results Programs.

In Windows 7, search results in the Start menu are very conveniently grouped, and the number of results in each group is immediately visible - this point has been improved compared to Windows Vista. As you can see in the screenshot, a search for the word word finds not only Microsoft Word and WordPad applications, but also offers results in other groups.

The Start menu displays multiple results for each group, and clicking on the group name opens a search box with all the search results for the group.

Searching in the Start menu is good when you have an idea of ​​the file name or its contents - the first 5 - 10 results are visible immediately, and you don’t have to look far. In addition, the Start menu is indispensable for quickly accessing programs and Control Panel items using search.

Main search window

A blank search window can be opened by pressing the keyboard shortcut WIN+F. It, in my opinion, has somewhat lost its meaning, since it no longer contains advanced file search capabilities. Searching in Explorer windows practically forces it out of the system. It seems to me that links to help on using search or a link to this article could brighten up its dull appearance.

However, the main search window still carries a payload. It opens with search results if you enter a query in the Start menu and click on the name of the search result group, or on View more results right above the search field.

Libraries

Now I will explain why I separated the search in libraries and other Explorer windows. Notice how library search results are displayed. They correspond to the type of files in it and are very well perceived visually. For example, for music files, the album cover, large song name, size are displayed, and there are also “musical” options for organizing the results. This is a property of all libraries, which confirms the thesis - the capabilities of Windows 7 are best used together. In this case, it is searching in libraries, which has other advantages.

This is what a simple library search will suggest: Music.

While in File Explorer, you can organize your search results by available file properties. The default display order is top scores, but, for example, you can organize music files by album or genre. This feature is available along with the traditional Explorer tools of sorting and grouping (although the latter may be new to Windows XP migrants).

In this case, the results will display several tracks from each album. You can view all the songs on an album, and then “fold” it if the one you need is not there.

If you don't find the file you need in the current folder, you can search again:

Other Explorer windows

In folders and libraries, the search field is the same as in the main window. But we must not forget that the same option is available in the “Open” and “Save As” windows, which are used even by those who prefer alternative file managers.

It is more convenient to search in folders when you know the approximate location of the file or document - in this case you will not get lost in the results. In addition, this method is useful when it is known for sure that the file is not included in the index. Finally, in the Open and Save As windows, you can quickly filter the contents of a folder using search.

I'm sure you've already tried simple search queries and you're probably completely satisfied with them. However, sooner or later you will need to find the file, and a simple query will not help with this. Next, I'll show you how to use Windows 7's advanced search capabilities to find the files you need.

New advanced search features in Windows 7

To master search, of course, you need to practice using its capabilities. In articles about Windows 7 search, I will give a number of examples that you can easily reproduce in your own home.

If you're upgrading from Windows XP, absolutely everything in your Windows 7 search will be new. Compared to Windows Vista, Windows 7 looks:

    have changed search filters

Search filters

When you roughly know the name of a file or the topic of a document, finding the desired file is usually not difficult - you simply enter a partial or full query into the Start menu search. But this information is not always stored in the RAM of the brain, and it is simply often necessary to set special search conditions - size, modification date, or author of the file. Windows XP had a search assistant, Windows Vista had filters.

At first glance, there is nothing that stands out visually in Windows 7. In fact, filters are still there - they just become visible when you place your cursor in the search field.

Advice. To see more filters, expand the search field - position the cursor on the separator between the field and the address bar and drag to the left.

In the screenshot you see a standard set of filters in the main search window.

Hints

Your search queries are remembered if they were entered:

    to the search window

    in explorer folder or library

    in the Start menu (assuming you navigated to results and didn't just open the file)

These prompts annoy some users, and they tend to turn them off immediately. And, in my opinion, they are doing it in vain. The tips remember not only search queries as such, but also filters searches that you specified - for example, the size or modification date of the file. Suggestions are very useful if you want to use the full power of Windows 7 search. It's easy to change the old condition to the current query, and it's faster than entering it again. And you can always delete an unnecessary hint - just select it (with the mouse or cursor) and press Delete on the keyboard.

As I said above, the new features of Windows 7 are best used together. The connection between search and libraries is not only in the display of results, but also in the formation of search conditions. In the next part of the article I will look at:

    using filters to search libraries and mail

    search in Internet Explorer 8

    search in non-indexed places

    search operators