4.Linux文件查找工具。

Linux经常使用locate与find作为文件查找命令。find可以认为是系统自带的命令,功能也挺多但是使用方法相对有点繁琐。find查找的是实时文件数据,一般用于查询明确知道文件目录及文件名的时候,可以按照参数将查询出来的文件做进一步操作如:打印、删除、执行命令等。find命令对使用者的要求比较高,要相当熟练的操作,但是功能相对丰富。

相对于find命令locate命令就比较简单而且效率比较快,因为locate命令安装时会创建一个档案数据库,里面记录了当前文件系统的文件数据,locate命令查找的就是这个数据库中的数据所以效率相对find命令会比较高。缺点就是因为数据库中的数据不会实时更新,如果最近修改了文件名那么可能使用该命令就会搜索不到文件。要更新数据库需要执行updatedb命令执行locate数据库。一般在crontab定时任务中会加入一个定时任务每天跑一次updatedb,这个动作一般都会在命令安装的时候自动设置一次(未经确认,请自行研究)。另外一个比较耐用的功能就是locate默认是模糊查找的哦,所以这里选择安装locate命令作为查找工具

root@454009d432a4:/# apt-cache search locate            //搜索locate安装包
mlocate - quickly find files on the filesystem based on their name    //我们要安装的资源
dlocate - fast alternative to dpkg -L and dpkg -S
gameconqueror - locate and modify a variable in a running process (GUI)
libcommons-discovery-java - locates classes that implement a given Java interfac
e
libcommons-discovery-java-doc - locates classes that implement a given Java inte
rface (documentation)
...
...
...
root@454009d432a4:/# apt-get install mlocate      //安装资源
...
...
... root@454009d432a4:/# locate -h          //命令说明
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.   -A, --all              only print entries that match all patterns
  -b, --basename         match only the base name of path names
  -c, --count            only print number of found entries
  -d, --database DBPATH  use DBPATH instead of default database (which is
                         /var/lib/mlocate/mlocate.db)
  -e, --existing         only print entries for currently existing files
  -L, --follow           follow trailing symbolic links when checking file
                         existence (default)
  -h, --help             print this help
  -i, --ignore-case      ignore case distinctions when matching patterns
  -p, --ignore-spaces    ignore punctuation and spaces when matching patterns
  -t, --transliterate    ignore accents using iconv transliteration when
                         matching patterns
  -l, --limit, -n LIMIT  limit output (or counting) to LIMIT entries
  -m, --mmap             ignored, for backward compatibility
  -P, --nofollow, -H     don't follow trailing symbolic links when checking file
                         existence
  -0, --null             separate entries with NUL on output
  -S, --statistics       don't search for entries, print statistics about each
                         used database
  -q, --quiet            report no error messages about reading databases
  -r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns
      --regex            patterns are extended regexps
  -s, --stdio            ignored, for backward compatibility
  -V, --version          print version information
  -w, --wholename        match whole path name (default)
root@454009d432a4:/# locate cron    //查找cron相关的文件
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/etc/cron.d/.placeholder
/etc/cron.daily/.placeholder
/etc/cron.daily/apt-compat
/etc/cron.daily/dpkg
/etc/cron.daily/mlocate      //安装mlocate资源时默认添加的每天定时任务
...
...
...

更详细的命令说明参考下面链接

资料来源链接:https://blog.csdn.net/looper66/article/details/55254682

5.Linux管道命令“|”

管道命令是命令模式下非常好用的技术,是一种将命令的结果作为其他命令的输入信息的技术。

该命令只能将命令的正确结果输出传递给下一个命令作为输入,如果命令报错则不能传递给下个命令

举例:

//正常的结果
root@454009d432a4:/# apt-cache search make | more      //将apt-cache search make 命令的输出结果作为more命令的输入信息,因为more命令有分页输出的效果所以就形成了分页输出搜索结果的效果
cmake-extras - Extra CMake utility modules
cmake-fedora - Set of scripts and cmake modules that simplify the release proces
s
cmake-qt-gui - Qt based user interface for CMake (cmake-gui)
colormake - simple wrapper around make to colorize output
colortail - log colorizer that makes log checking easier
--More-- //错误的结果
root@454009d432a4:/# 66666 | apt-cache search    //如果66666不是一个正确的命令所以apt-cache search没有输入,这时候相当于两个命令都会报错
bash: 66666: command not found            //66666的错误提示
E: You must give at least one search pattern    //apt-cache search的错误提示

资料链接:https://blog.csdn.net/wirelessqa/article/details/8968381

6.Linux命令输出重定向“>”、“>>”

管道命令的概念其实跟 “>”与“>>”符号的概念非常像。只不过“>”与“>>”符号一般只作用于文件而不是命令。

以下将“>”与“>>”暂且称为输出重定向符号。输出重定向符号的作用是将命令的正确输出重定向到指定文件中(即写入到指定文件中),如果文件不存在则新增文件。“>”,“>>”区别在于“>”是将文件中的内容覆盖为输出内容,“>>”是在文件后面追加输出内容。例如:

root@454009d432a4:/# apt-cache search net-tools >> workdir/check.log    //将apt-cache search net-tools的结果写入workdir/check.log文件中,如果文件不存在自动创建文件
root@454009d432a4:/# apt-cache search net-tools > workdir/check.log    //将apt-cache search net-tools的结果覆盖workdir/check.log文件中的内容,如果文件不存在自动创建文件

资料链接:https://blog.csdn.net/qq_36076233/article/details/69061684

Linux学习之路(二)的更多相关文章

  1. Linux学习之CentOS(二十二)--单用户模式下修改Root用户的密码

    在上一篇随笔里面详细讲解了Linux系统的启动过程 (Linux学习之CentOS(二十一)--Linux系统启动详解),我们知道Linux系统的启动级别一共有6种级别,通过 /etc/inittab ...

  2. deepin linux 学习笔记(二)——文本编辑器

    目录 deepin linux 学习笔记(二)--文本编辑器 前言 nano 小巧的命令行编辑器 通用 编辑 定位 排版 配置 vim 思路独特的超级编辑器 命令模式 插入模式 底线模式(末行模式) ...

  3. Linux学习之CentOS(二)--初识linux的一些常用命令

    Linux学习之CentOS(二)--初识linux的一些常用命令 在VM上安装完了CentOS6.4以后,看着linux系统成功跑起来,心里小激动了一把......但是前方学习的道路还很遥远... ...

  4. Linux学习之CentOS(二十六)--Linux磁盘管理:LVM逻辑卷的创建及使用

    在上一篇随笔里面 Linux学习之CentOS(二十五)--Linux磁盘管理:LVM逻辑卷基本概念及LVM的工作原理,详细的讲解了Linux的动态磁盘管理LVM逻辑卷的基本概念以及LVM的工作原理, ...

  5. Linux学习之路-Linux-at及cron命令【7】---20171215

    Linux学习之路-Linux-at及cron命令[7]---20171215 DannyExia000人评论986人阅读2017-12-24 17:28:03   ntpdate 命令 [root@ ...

  6. Linux学习之路(一)

    导语: 早前为了方便日常开发,建立跟生产环境类型的环境的时候考虑使用docker作为模拟生产环境,结果没想到给自己的学习挖了一个大坑.其他关于docker容器技术的坑先不在这里赘述,有时间的话在其他文 ...

  7. Linux 学习总结(二)

    一.用户与用户组管理 1.添加用户 useradd 选项 用户名 -c 指定一段注释性描述 -d 目录,指定用户目录,若目录不存在,-m 选项可以创建目录 -g 指定用户所属用户组 -s 指定用户登陆 ...

  8. 我的Linux学习之路及参考书籍

    学习目的 很简单的考虑,最近在各大招聘网站上找工作,发现多数c/c++开发职位都需要Linux开发经验,让我很苦恼,因为Linux我到目前为止知之甚少,知道Linux的概念,也在大学期间了解过一段时间 ...

  9. 新手小白的Linux学习之路

    大家好,我是一个零基础的新手小白,在此和大家分享一下新手小白的学习之路.欢迎各位大神指教!谢谢 Linux简介: Linux操作系统诞生于1991年10月,由芬兰赫尔辛基大学的在校生Linus Tor ...

  10. Redis——学习之路二(初识redis服务器命令)

    上一章我们已经知道了如果启动redis服务器,现在我们来学习一下,以及如何用客户端连接服务器.接下来我们来学习一下查看操作服务器的命令. 服务器命令: 1.info——当前redis服务器信息   s ...

随机推荐

  1. sequelize问题集锦

    查询: 查询在指定时间范围内的所有数据 options.where.crawl_time = { $lt: new Date('2017-04-08 00:00:00'), $gt: new Date ...

  2. 说一说MVC的Authentication过滤(四)

    前沿: 一般情况下,在我们做访问权限管理的时候,会把用户的正确登录后的基本信息保存在Session中,以后用户每次请求页面或接口数据的时候,拿到 Session中存储的用户基本信息,查看比较他有没有登 ...

  3. Redis哨兵

    Redis Sentinel Redis哨兵为Redis提供高可用.这就意味着你用哨兵可以创建一个Redis部署,在没有人为干预的情况下抵抗某些失败.(PS:自动故障转移) Redis哨兵还提供其他的 ...

  4. CentOS 7 安装 Jenkins

    准备工作 首选需要安装JAVA环境 https://www.cnblogs.com/stulzq/p/9286878.html 如果你的系统没有自带git,那么也需要安装一个 yum install ...

  5. redis 系列18 事件

    一.概述 Redis服务器是一个事件驱动程序,服务器需要处理两类事件:1文件事件,2时间事件.文件事件是关于客户端与服务器之间的通信操作.时间事件是关于服务器内部的一些定时操作.本篇还是参照" ...

  6. 【干货】Chrome插件(扩展)开发全攻略

    写在前面 我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的,所以转载务必保留出处.本文所有涉及到的大部分代码均在这个demo里面:https://github ...

  7. SpringCloud Ribbon的分析(二)

    上文我们分析到 loadBalancer 根据具体的算法选择相应的server. protected Server getServer(ILoadBalancer loadBalancer) { if ...

  8. Spring 完美配置跨域请求

    在SpringBoot2.0 上的跨域 用以下代码配置 即可完美解决你的前后端跨域请求问题 import org.springframework.context.annotation.Bean; im ...

  9. centos 7 linux系统安装 mysql5.7.17(glibc版)

    前言:经过一天半的折腾,终于把 mysql 5.7.17 版本安装上了 centos 7 系统上,把能参考的博客几乎都看了一遍,终于发现这些细节问题,然而翻了无数的文章,基本上都没有提到这些,所以小生 ...

  10. centos6.5-vsftp搭建

    我的机子是默认是没有的vsftp. yum install -y vsftp 创建账户专为ftp而生.useradd ftp01 更改账户不可登录系统.usermod -s /sbin/nologin ...