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定位
  • grepgrep
  • which哪一个
  • whereis哪里

查找命令(Find Command)

findcommand is very featureful command used with a lot of different options. More details about find command 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 named conf in 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 match conffff, myconf, myconfffff, myconfiguration.txt etc.

我们可以通过将文件类型设置为-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 /etc path.

或者,我们可以指定要搜索给定文件名的路径。 我们将根据提供路径. 。 在此示例中,我们将在/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)

locate command can be used as an offline database of all files and folders. locate will search a database which is created with updatedb command. More detailed information can get from the following tutorial.

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

locate Command Tutorial With Examples For Linux To Find Files

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

.ud46b850bc54e6071f7f0d217ddc51187 , .ud46b850bc54e6071f7f0d217ddc51187 .postImageUrl , .ud46b850bc54e6071f7f0d217ddc51187 .centered-text-area { min-height: 80px; position: relative; } .ud46b850bc54e6071f7f0d217ddc51187 , .ud46b850bc54e6071f7f0d217ddc51187:hover , .ud46b850bc54e6071f7f0d217ddc51187:visited , .ud46b850bc54e6071f7f0d217ddc51187:active { border:0!important; } .ud46b850bc54e6071f7f0d217ddc51187 .clearfix:after { content: ""; display: table; clear: both; } .ud46b850bc54e6071f7f0d217ddc51187 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .ud46b850bc54e6071f7f0d217ddc51187:active , .ud46b850bc54e6071f7f0d217ddc51187:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .ud46b850bc54e6071f7f0d217ddc51187 .centered-text-area { width: 100%; position: relative; } .ud46b850bc54e6071f7f0d217ddc51187 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .ud46b850bc54e6071f7f0d217ddc51187 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .ud46b850bc54e6071f7f0d217ddc51187 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .ud46b850bc54e6071f7f0d217ddc51187:hover .ctaButton { background-color: #E67E22!important; } .ud46b850bc54e6071f7f0d217ddc51187 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .ud46b850bc54e6071f7f0d217ddc51187 .ud46b850bc54e6071f7f0d217ddc51187-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .ud46b850bc54e6071f7f0d217ddc51187:after { content: ""; display: block; clear: both; }

LEARN MORE  How To Use Grep Command Recursively Through Sub-Directories In Linux?

.ud46b850bc54e6071f7f0d217ddc51187 , .ud46b850bc54e6071f7f0d217ddc51187 .postImageUrl , .ud46b850bc54e6071f7f0d217ddc51187 .centered-text-area { min-height: 80px; position: relative; } .ud46b850bc54e6071f7f0d217ddc51187 , .ud46b850bc54e6071f7f0d217ddc51187:hover , .ud46b850bc54e6071f7f0d217ddc51187:visited , .ud46b850bc54e6071f7f0d217ddc51187:active { border:0!important; } .ud46b850bc54e6071f7f0d217ddc51187 .clearfix:after { content: ""; display: table; clear: both; } .ud46b850bc54e6071f7f0d217ddc51187 { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .ud46b850bc54e6071f7f0d217ddc51187:active , .ud46b850bc54e6071f7f0d217ddc51187:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .ud46b850bc54e6071f7f0d217ddc51187 .centered-text-area { width: 100%; position: relative; } .ud46b850bc54e6071f7f0d217ddc51187 .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .ud46b850bc54e6071f7f0d217ddc51187 .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .ud46b850bc54e6071f7f0d217ddc51187 .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .ud46b850bc54e6071f7f0d217ddc51187:hover .ctaButton { background-color: #E67E22!important; } .ud46b850bc54e6071f7f0d217ddc51187 .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .ud46b850bc54e6071f7f0d217ddc51187 .ud46b850bc54e6071f7f0d217ddc51187-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .ud46b850bc54e6071f7f0d217ddc51187:after { content: ""; display: block; clear: both; }

了解更多如何在Linux中通过子目录递归使用Grep命令?

As locate database only holds file and folder names we can not search in detail. But this database provides us very fast search option then find command because it works offline.

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

更新数据库 (Update Database)

As stated previously locate uses 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 use locate command and the file and folder name to search.

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

$ locate /home/ismail/*back*

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

Grep命令(Grep Command)

grep command 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 use ls command recursively and grep the files and folder we want to find. In this example, we will search for files and folders whose names contain backup .

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

$ ls -R -l | grep backup

Grep Command
Grep命令

哪个命令(Which Command)

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

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

$ which ls

Whereis命令 (Whereis Command)

whereis command is used to list given search term related binary, source, or man page files. In this example, we will search for ls binary and related man page files.

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

$ whereis ls

翻译自: https://www.poftut.com/find-files-folders-directories-linux-command-line/

linux 查找文件夹命令

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

  1. java url 本地文件是否存在_我的应用程序知道URL中是否存在文件会一直停止[重复]...

    这个问题在这里已有答案: 我试图写一个应用程序,如果在给定的URL中有一个文件,将字符串放在textview中,这是代码和崩溃信息,可能是什么错误? public class MainActivity ...

  2. bin文件如何编辑_如何为高通固件创建rawprogram0和patch0文件

    这是一个分步教程,显示如何为Qualcomm固件创建rawprogram0.xml和patch0.xml文件. 要求 下载并安装Python @ https://www.python.org/down ...

  3. openstack常用运维命令_运维人员常用的Linux命令汇总

    作为运维人员,这些常用命令不得不会,掌握这些命令,工作上会事半功倍,提供工作效率. 一.文件和目录 cd命令,用于切换当前目录,它的参数是要切换到的目录的路径,可以是绝对路径,也可以是相对路径. cd ...

  4. linux vim命令_提升生产力的20大Linux Vim命令

    linux vim命令 VIM or the Vi Improved text editor is one of the most advanced text editors available. L ...

  5. centos找不到chattr命令_一个骚命令防止你的文件被误删除!

    大家好,我是良许. 文件是我们在电脑里最珍贵的财富,我们经常工作了老半天,然后出来的成果就只是一个文件而已.特别是程序员,我们写了半天的代码,结果也就是一个个代码文件而已. 但是,我们都有过这样惨痛的 ...

  6. debian查看ip地址命令_鲜为人知而又实用的 Linux 命令大全

     点击"Cisco思科CCIE俱乐部"→点击右上角"..."→"设为星标"   资讯丨干货丨入群 联系小E微信:SPOTO123456 Li ...

  7. lxrun不是内部或外部命令_在Win10 安装 WSL的Linux子系统,解决cmd中执行lxrun时提示“不是内部或外部命令”...

    Win10 安装Linux子系统原理就是安装一个(Linux系统的)应用程序.使用应用程序一般的使用Linux子系统,非常方便. 第一步:启用开发者模式 启用开发者模式,其实很简单,本人参考的是该文章 ...

  8. java代码执行linux命令_怎么用java代码运行linux命令

    展开全部 以下方法支持Linux和windows两个系统的命令行调用.还用到了apache的lang工具包32313133353236313431303231363533e78988e69d83313 ...

  9. find命令_用find命令查找文件目录

    find 命令: 目的:查找符合指定条件的文件 格式:find 目录名 选项 查找条件 举例1: 说明: /Users/lanjingui/Desktop/指明了find命令所查找的目录路径 -nam ...

最新文章

  1. SignalR实现服务器与客户端的实时通信
  2. linux火狐浏览器49.0安装教程,火狐浏览器Linux最新版下载
  3. 两大硬件设计被OCP官方接受,腾讯成国内互联网公司第一家
  4. mobx中的数组需要注意的地方
  5. 甘特图看起来很生硬?教你使用智能颜色装饰你的甘特图!(一)
  6. Informatica 简单使用
  7. 计算机网络—三种CSMA协议
  8. java软件工程师工作业绩_JAVA软件工程师个人简历范文
  9. ubuntu重装显卡驱动
  10. 已在此计算机上安装了此应用cad,电脑安装CAD时提示已安装导致安装失败的问题如何解决...
  11. Spark Streaming简单入门(示例+原理)
  12. 齐齐哈尔大学计算机调剂,2020年齐齐哈尔大学硕士研究生调剂复试工作方案
  13. MySQL学习2:表的创建和增删改
  14. 华为路由器静态路由协议配置
  15. [个人资料整理]游戏类型总结
  16. 车牌识别停车场管理系统中 无感支付停车
  17. HowTo如何制作一个文字冒险游戏-里篇(1)
  18. pylint代码检查常见警告、提示的解决方法记录
  19. 检测到域名被墙如何解决?域名被墙怎么快速恢复?
  20. 树莓派远程4G遥控车教程(三)-摄像头安装及实现局域网实时监控

热门文章

  1. 八叉树 java_八叉树(Octree)
  2. lrzsz命令的用法
  3. Spring第8篇:自动注入(autowire)详解
  4. smarty模板引擎--php高级最详细教程
  5. CVPR2022 | ZeroCap:零样本图像到文本生成的视觉语义算法
  6. 左右互搏:GAN在爱奇艺短视频推荐冷启动中的实践
  7. 搭建SpringBoot项目阶段-groupId和artifactId
  8. 装系统时提示:无法打开所需文件,错误代码0x8007000D解决方案
  9. Mysql 数据库自动备份
  10. python 3 | doc转docx