window重启命令

Windows operating systems provide the tool named find to search text files for a given term or string. Linux also have a command with the same name but it is used to search files and folders names

Windows operating systems provide the tool named find to search text files for a given term or string. Linux also have a command with the same name but it is used to search files and folders names not file contents. Windows find command is very simple and easy command to work.

Windows操作系统提供名为find的工具,以在文本文件中搜索给定的术语或字符串。 Linux也有一个具有相同名称的命令,但是它用于搜索文件和文件夹名称,而不是文件内容。 Windows find命令非常简单易用。

帮帮我 (Help)

Help information about the find command can be printed with the /? option like below.

可以使用/?打印关于find命令的帮助信息/? 如下所示的选项。

find /?

Help
Help
帮帮我

句法(Syntax)

Syntax of the find command provides options , string to search and file or drive or path to be searched.

find命令的语法提供options,要搜索的字符串以及要搜索的文件或驱动器或路径。

FIND [options] "string" [[drive:][path]filename[ ...]]

查找字符串 (Find String)

We will simple made a search in files. We will do not provide any option. Given term will be search in given file , path or drive. In this example we will search the term ismail in C:\users.txt .

我们将简单地在文件中进行搜索。 我们将不提供任何选择。 给定术语将在给定文件,路径或驱动器中搜索。 在此示例中,我们将在C:\users.txt搜索术语ismail

$ find "ismail" C:\users.txt

Find String
Find String
查找字符串

From output we can see that the term ismail is found. The filename also given because multi file search.

从输出中我们可以看到找到了术语ismail 。 也提供文件名,因为可以进行多文件搜索。

搜索多个文件 (Search Multiple Files)

In previous example we have searched single for for given string. Find command also supports for searching multiple file with a single command. We do not specify an option. We will just use * for file name. * means all files those exists given path.  We can also specify a path before * .

在前面的示例中,我们已在single中搜索给定的字符串。 查找命令还支持使用单个命令搜索多个文件。 我们没有指定选项。 我们将仅使用*作为文件名。 *表示所有存在给定路径的文件。 我们还可以在*之前指定路径。

$ find "ismail" *

Search Multiple Files
Search Multiple Files
搜索多个文件

Or we will search a given paths all files.

否则我们将搜索给定路径的所有文件。

$ find "ismail" C:\users\ismail\*

As we see find command search all files like text, binary, picture etc.

如我们所见,find命令搜索所有文件,例如文本,二进制文件,图片等。

搜索具有特定扩展名的文件 (Search Files With Specific Extension)

Previous example show how to search all files without filtering them according to their extension. We can give specific extension to search. We will use * / asterisk again but we will also specify the extension of file. In this example we will search in text files where they extension is .txt

前面的示例显示了如何搜索所有文件而不根据其扩展名过滤它们。 我们可以为搜索提供特定的扩展名。 我们将再次使用* /星号,但我们还将指定文件的扩展名。 在此示例中,我们将搜索扩展名为.txt文本文件

$ find "ismail" *.txt

Search Files With Specific Extension
Search Files With Specific Extension
搜索具有特定扩展名的文件

打印行号(Print Line Numbers)

While searching terms there may be more than one occurence of the given string. We may need to print the line number of the match. This can be done with /N option.

在搜索术语时,给定的字符串可能会出现多次。 我们可能需要打印匹配项的行号。 可以使用/N选项来完成。

$ find /N "ismail" *.txt

Print Line Numbers
Print Line Numbers
打印行号

As we can se from result USERS.TXT file line number 1 have a match

我们可以从结果USERS.TXT文件第1行中找到匹配项

LEARN MORE  How To Check If String Contains A Specific Word in PHP?

知秋君
上一篇 2024-08-25 09:12
下一篇 2024-08-25 08:48

相关推荐