locate

Centos7——9.实用指令(搜索查找类)

蓝咒 提交于 2019-11-27 19:35:37
目录 1. find 指令 2. locate 指令 3. grep 指令 和 管道符号 | 1. find 指令 find 指令将从指定目录向下递归地遍历其各个子目录,将满座条件的文件或者目录显示在终端。 基本语法 find [搜索范围] [选项] 选项说明 图1 应用实例 案例1:按文件名:根据名称查找 /home 目录下的 hello.txt 文件 图2 案例2:按拥有者:查找 /opt 目录下,用户名称为 nobody 的文件 图3 案例3:查找整个 linux 系统下大于 20m 的文件 (+n 大于 -n小于 n等于) 图4 1m = 1024k 图5 查询 / 目录下,所有 .txt 的文件 图6 2. locate 指令 locate 指令可以快速定位文件路径。locate 指令利用事先建立的系统中所有文件名称及路径的 locate 数据库实现快速定位给定的文件。locate 指令无需遍历整个文件系统,查询速度较快。为了保证查询结果的准确度,管理员必须定期更新 locate 时刻。 基本语法 locate 搜索文件 特别说明 由于 locate 指令基于数据库进行查询,所以第一次运行前,必须使用 updatedb 指令创建 locate 数据库。 应用实例 案例1:使用 locate 指令快速定位 hello.txt 文件所在目录 图7 3. grep 指令 和

文件查找

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:19:09
文件查找和压缩 文件查找 在文件系统上查找符合条件的文件 locate命令:模糊查locate,非实时需手动执行更新数据库updatedb -i:不区分大小写的搜索 示列locate -i pasSSWd -n:只列出查询出结果的前三个 示列:locate -n3 passwd -r:使用基本正则表达式需要加r 示列:locate -r ‘.conf$’ find命令:实时查找工具,通过遍历指定路径完成文件查找 -maxdepth:最大搜索目录深度,指定目录下的文件为1级 -depth:先处理目录内的文件,再处理指定目录 示列:find /tmp/ -maxdepth 2 -name wujiancong -mindepth:查看不小于多深的文件,不低于所限内容 示列:find /etc -mindepth 4 -name .conf -name:“文件名称” 支持glob函数 ,?,[],[^] -iname:“文件名称” 不区分大小写查找 -inum:按inode号查找 -samefile name 相同inode号的文件 -regex:以模式匹配整个文件路径,而非文件名称 示列:find /etc -regex “. .sh$" 根据属主、属组查找 -user username :查找属主为指定用户UID的文件 示列:find -user wjc -group grpname

locate,find,sed,包管理,文件解压缩

妖精的绣舞 提交于 2019-11-27 18:59:56
本周学习内容知识点总结与实践 本周总共分为四大点和一个补充点sed行编辑器、文件查找、文件压缩解压、软件包管理。 现在开始逐个分解讲解其功能及实践操作的截图 一、文件查找:在文件系统上查找符合条件的文件 locate命令 : 用来查找文件或目录,locate命令查找比find快,比如在/tmp下新建了一个xx文件夹,此时再使用locate去查找xx文件夹时发现无法找到文件夹,因为locate是事先把系统内所有档案名称及路径都索引到数据库了,在使用时尽量手动操作updatedb更新数据库。 选项 -i:不区分大小写的搜索 示列locate -i pasSSWd -n:只列出查询出结果的前三个 示列:locate -n3 passwd -r:使用基本正则表达式需要加r 示列:locate -r '\.conf$' find命令 :实时查找工具,通过遍历指定路径完成文件查找 选项 -maxdepth:最大搜索目录深度,指定目录下的文件为1级 -depth:先处理目录内的文件,再处理指定目录 示列:find /tmp/ -maxdepth 2 -name wujiancong -mindepth:查看不小于多深的文件,不低于所限内容 示列:find /etc -mindepth 4 -name *.conf -name:“文件名称” 支持glob函数 *,?,[],[^] -iname:

linux中whereis、which、find、location的区别和用法

别说谁变了你拦得住时间么 提交于 2019-11-27 12:03:55
摘自:https://www.cnblogs.com/kex1n/p/5233821.html 1. find find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件。 find的使用格式如下:    $ find <指定目录> <指定条件> <指定动作>   - <指定目录>: 所要搜索的目录及其所有子目录。默认为当前目录。   - <指定条件>: 所要搜索的文件的特征。   - <指定动作>: 对搜索结果进行特定的处理。 如果什么参数也不加,find默认搜索当前目录及其子目录,并且不过滤任何结果(也就是返回所有文件),将它们全都显示在屏幕上。 find的使用实例:    $ find . -name "my*" 搜索当前目录(含子目录,以下同)中,所有文件名以my开头的文件。    $ find . -name "my*" -ls 搜索当前目录中,所有文件名以my开头的文件,并显示它们的详细信息。    $ find . -type f -mmin -10 搜索当前目录中,所有过去10分钟中更新过的普通文件。如果不加-type f参数,则搜索普通文件+特殊文件+目录。 2. locate locate命令其实是“find -name”的另一种写法,但是要比后者快得多,原因在于它不搜索具体目录,而是搜索一个数据库(/var/lib/locatedb)

Find all files with name containing string

强颜欢笑 提交于 2019-11-27 05:57:29
I have been searching for a command that will return files from the current directory which contain a string in the filename. I have seen locate and find commands that can find files beginning with something first_word* or ending with something *.jpg . How can I return a list of files which contain a string in the filename? For example, if 2012-06-04-touch-multiple-files-in-linux.markdown was a file in the current directory. How could I return this file and others containing the string touch ? Using a command such as find '/touch/' Use find : find . -maxdepth 1 -name "*string*" -print It will

linux学习(四)-----linux常用指令

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 03:59:28
touch 指令 touch 指令创建空文件 基本语法 touch 文件名称 应用实例 案例 1: 创建一个空文件 hello.txt cp 指令 cp 指令拷贝文件到指定目录 基本语法 cp [选项] source dest 常用选项 -r :递归复制整个文件夹 应用实例 案例 1: 将 /home/aaa.txt 拷贝到/home/bbb 目录下[拷贝单个文件] 案例 2: 递归复制整个文件夹,举例将/home/test 整个目录拷贝到 /home/zwj 目录 使用细节 强制覆盖不提示的方法:\cp rm 指令 rm 指令移除【删除】文件或目录 基本语法 rm [选项] 要删除的文件或目录 常用选项 -r :递归删除整个文件夹 -f : 强制删除不提示 应用实例 案例 1: 将 /home/aaa.txt 删除 案例 2: 递归删除整个文件夹 /home/bbb 使用细节 强制删除不提示的方法:带上 -f 参数即可 mv 指令 mv 移动文件与目录或重命名 基本语法 mv oldNameFile newNameFile (功能描述:重命名) mv /temp/movefile /targetFolder (功能描述:移动文件) 应用实例 案例 1: 将 /home/aaa.txt 文件 重新命名为 pig.txt 案例 2:将 /home/pig.txt文件 移动到

[UNIX] where is, locate command

泄露秘密 提交于 2019-11-26 18:22:28
3個非常有用的指令 1. whereis 找到程式安裝的目錄 語法如下: whereis <關鍵字> 例如: whereis java 執行結果範例如下: [vl77@STIMCAS01 dse- 2.1 ]$ whereis java java: /usr/bin/ java 2. updatedb http://linux.vbird.org/linux_basic/0220filemanager.php#locate 手動更新locate 資料庫 3. locate 語法如下: locate <關鍵字> 例如: locate Cassandra 執行結果範例如下: [vl77@STIMCAS01 dse- 2.1 ]$ locate Cassandra /usr/lib/python2. 6 /site-packages/cql/cassandra/ Cassandra.py /usr/lib/python2. 6 /site-packages/cql/cassandra/ Cassandra.pyc /usr/lib/python2. 6 /site-packages/cql/cassandra/ Cassandra.pyo /usr/local/dse- 2.1 /interface/gen-py/cassandra/Cassandra- remote /usr

Find all files with name containing string

我的未来我决定 提交于 2019-11-26 11:46:43
问题 I have been searching for a command that will return files from the current directory which contain a string in the filename. I have seen locate and find commands that can find files beginning with something first_word* or ending with something *.jpg . How can I return a list of files which contain a string in the filename? For example, if 2012-06-04-touch-multiple-files-in-linux.markdown was a file in the current directory. How could I return this file and others containing the string touch