300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux 查找文件夹命令_如何从命令行在Linux中查找文件 文件夹和目录?

linux 查找文件夹命令_如何从命令行在Linux中查找文件 文件夹和目录?

时间:2022-07-11 09:46:29

相关推荐

linux 查找文件夹命令_如何从命令行在Linux中查找文件 文件夹和目录?

linux 查找文件夹命令

Linux provides different ways to find and locate files and folders. We can use GUI tools like GNOME and KDE file managers or other 3’rd party applications designed for finding files. In this tutorial, we will look at how to find files, folders, and directories from the command line.

Linux提供了多种查找和定位文件和文件夹的方法。 我们可以使用GNOME和KDE文件管理器之类的GUI工具,也可以使用其他旨在查找文件的第三方应用程序。 在本教程中,我们将研究如何从命令行查找文件,文件夹和目录。

在Linux中查找文件和文件夹的工具 (Tools To Find Files and Folder In Linux)

As stated previously there are a lot of tools that can be used to find files and folders. We will look in detail all of them. Here list of these tools.

如前所述,有很多工具可用于查找文件和文件夹。 我们将详细介绍所有这些。 这里列出这些工具。

find找 locate定位grepgrepwhich哪一个 whereis哪里

查找命令(Find Command)

findcommand is very featureful command used with a lot of different options. More details aboutfindcommand can be found from the following tutorial.

find命令是非常有特色的命令,它具有许多不同的选项。 可从以下教程中找到有关find命令的更多详细信息。

Linux Find Command With Examples

Linux使用示例查找命令

仅查找文件(Find Only Files)

We can search only files by providing file type as-type f. We will search files those namedconfin this example. We will use the glob start and end of the search term in order to accept any prefix or postfix for the search term. So this will matchconffff,myconf,myconfffff,myconfiguration.txtetc.

我们可以通过将文件类型设置为-type f来仅搜索文件。 在此示例中,我们将搜索名为conf文件。 我们将使用全球范围内搜索词的开头和结尾,以便接受搜索词的任何前缀或后缀。 因此,这将匹配conffffmyconfmyconfffffmyconfiguration.txt等。

$ find . -type f -name "*conf*"

Find Only Files
仅查找文件

Alternatively, we can specify the path we want to search for the given file name. We will provide the path according to.. In this example, we will search in the/etcpath.

或者,我们可以指定要搜索给定文件名的路径。 我们将根据提供路径.。 在此示例中,我们将在/etc路径中搜索。

$ find /etc -type f -name "*conf*"

Find Only Files
仅查找文件

仅查找文件夹(Find Only Folders)

We may need only to find the folder. We will specify the type like below a directory.

我们可能只需要找到该文件夹​​。 我们将在目录下指定类型。

$ find . -type d -name "*conf*"

Find Only Folders
仅查找文件夹

查找命令(Locate Command)

locatecommand can be used as an offline database of all files and folders.locatewill search a database which is created withupdatedbcommand. More detailed information can get from the following tutorial.

locate命令可以用作所有文件和文件夹的脱机数据库。locate将搜索使用updatedb命令创建的数据库。 可以从以下教程中获得更多详细信息。

locate Command Tutorial With Examples For Linux To Find Files

使用Linux查找文件的示例找到命令教程

LEARN MORE How To Use Grep Command Recursively Through Sub-Directories In Linux?了解更多如何在Linux中通过子目录递归使用Grep命令?

Aslocatedatabase only holds file and folder names we can not search in detail. But this database provides us very fast search option thenfindcommand because it works offline.

由于locate数据库仅包含文件和文件夹名称,因此我们无法详细搜索。 但是此数据库为我们提供了非常快速的搜索选项,然后提供了find命令,因为它可以脱机工作。

更新数据库 (Update Database)

As stated previouslylocateuses a database to search files and folders. Updating this database is important before a search. The update will take very little time.

如前所述,locate使用数据库来搜索文件和文件夹。 搜索之前更新此数据库很重要。 更新将花费很少的时间。

$ updatedb

搜索文件或文件夹 (Search For File or Folders)

We will uselocatecommand and the file and folder name to search.

我们将使用locate命令以及文件和文件夹名称进行搜索。

$ locate /home/ismail/*back*

Search For File or Folders
搜索文件或文件夹

Grep命令(Grep Command)

grepcommand mainly filters given text and files contents but we can use it to find files and folders. For more detail

grep命令主要过滤给定文本和文件内容,但是我们可以使用它来查找文件和文件夹。 欲了解更多信息

Introduction to Linux Grep Command With Examples

Linux Grep命令简介和示例

We can uselscommand recursively and grep the files and folder we want to find. In this example, we will search for files and folders whose names containbackup.

我们可以递归使用ls命令,并grep我们要查找的文件和文件夹。 在此示例中,我们将搜索名称包含backup文件和文件夹。

$ ls -R -l | grep backup

Grep Command
Grep命令

哪个命令(Which Command)

whichcommand is not an actual file and folder search.whichcommand simply search current environment executable files. This is generally useful if we are looking for a command which is not included inPATHvariable and can not use automatically.

which命令不是实际的文件和文件夹搜索。which命令仅搜索当前环境的可执行文件。 如果我们要寻找一个不包含在PATH变量中并且不能自动使用的命令,这通常很有用。

$ which ls

Whereis命令 (Whereis Command)

whereiscommand is used to list given search term related binary, source, or man page files. In this example, we will search forlsbinary and related man page files.

whereis命令用于列出与给定搜索词相关的二进制,源或手册页文件。 在此示例中,我们将搜索ls二进制文件和相关的手册页文件。

$ whereis ls

翻译自: /find-files-folders-directories-linux-command-line/

linux 查找文件夹命令

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。