美文网首页
linux文件查看类命令总结及演示

linux文件查看类命令总结及演示

作者: 香吉矢 | 来源:发表于2017-08-23 21:58 被阅读0次

head,tail,cat,more,less

head
  • image.png
  • 命令演示
    [root@localhost mytest]# head -n 12 passwd.test
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    root:x:0:0:root:/root:/bin/bash
    [root@localhost mytest]# head -12 passwd.test
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    root:x:0:0:root:/root:/bin/bash

tail
  • image.png
  • 命令演示
    [root@localhost mytest]# tail -n 3 passwd.test
    ntp:x:38:38::/etc/ntp:/sbin/nologin
    avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
    tcpdump:x:72:72::/:/sbin/nologin
    [root@localhost mytest]#
    [root@localhost mytest]# tail -3 passwd.test
    ntp:x:38:38::/etc/ntp:/sbin/nologin
    avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
    tcpdump:x:72:72::/:/sbin/nologin

    • 另开一ssh窗口,对passwd文件进行修改
      [root@localhost mytest]# tty
      /dev/pts/4
      [root@localhost mytest]# echo 'linux centos fedora suse RHEL' >> passwd
      [root@localhost mytest]# echo 'linux centos fedora suse RHEL' >> passwd
      [root@localhost mytest]# echo 'linux centos fedora suse RHEL' >> passwd
      [root@localhost mytest]# echo 'linux centos fedora suse RHEL' >> passwd
      [root@localhost mytest]# echo 'linux centos fedora suse RHEL' >> passwd
    • 在第一个ssh窗口,执行查看命令 tail -f passwd,不会自动退出文件,可以看到文件内容在增加
      [root@localhost mytest]# tail -f passwd
      3
      4
      5
      6
      7
      8
      9
      10
      11
      linux centos fedora suse RHEL
      linux centos fedora suse RHEL
      linux centos fedora suse RHEL
      linux centos fedora suse RHEL
      linux centos fedora suse RHEL
cat
  • image.png
  • 命令演示
    [root@localhost mytest]# cat redhat-release
     
     
     
    CentOS Linux release 7.3.1611 (Core)
     
     
    [root@localhost mytest]# cat version
    Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016
    [root@localhost mytest]# cat redhat-release version
     
     
     
    CentOS Linux release 7.3.1611 (Core)
     
     
    Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016
    [root@localhost mytest]# cat > newfile
    my name is zhanmusi
    see you next week
    ^C
    [root@localhost mytest]#
    [root@localhost mytest]# cat newfile
    my name is zhanmusi
    see you next week
    [root@localhost mytest]# cat hebing
    cat: hebing: 没有那个文件或目录
    [root@localhost mytest]# cat redhat-release redhat-release newfile > hebing
    [root@localhost mytest]# cat hebing
     
     
     
    CentOS Linux release 7.3.1611 (Core)
     
     
     
     
     
    CentOS Linux release 7.3.1611 (Core)
     
     
    my name is zhanmusi
    see you next week
    [root@localhost mytest]# cat -n hebing
    1
    2
    3
    4 CentOS Linux release 7.3.1611 (Core)
    5
    6
    7
    8
    9
    10 CentOS Linux release 7.3.1611 (Core)
    11
    12
    13 my name is zhanmusi
    14 see you next week
    [root@localhost mytest]# cat -b hebing
     
     
     
    1 CentOS Linux release 7.3.1611 (Core)
     
     
     
     
     
    2 CentOS Linux release 7.3.1611 (Core)
     
     
    3 my name is zhanmusi
    4 see you next week
    [root@localhost mytest]# cat -E hebing
    $
    $
    $
    CentOS Linux release 7.3.1611 (Core)$
    $
    $
    $
    $
    $
    CentOS Linux release 7.3.1611 (Core)$
    $
    $
    my name is zhanmusi$
    see you next week$
    [root@localhost mytest]#

more
  • image.png
  • 命令演示
    [root@localhost mytest]# more -15 fstab.test
    1
    2
    3
    4
    5
     
     
     
     
     
    # /etc/fstab
    # Created by anaconda on Tue May 30 06:31:44 2017

# Accessible filesystems, by reference, are maintained under '/dev/disk'
--More--(32%)
[root@localhost mytest]# more +5 fstab.test
5

# /etc/fstab
# Created by anaconda on Tue May 30 06:31:44 2017

# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=8be7dbe5-dde6-40b0-8900-c30f1007287e /boot xfs defaul
ts 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[root@localhost mytest]# more -s fstab.test
1
2
3
4
5

# /etc/fstab
# Created by anaconda on Tue May 30 06:31:44 2017

# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

/dev/mapper/cl-root / xfs defaults 0 0
UUID=8be7dbe5-dde6-40b0-8900-c30f1007287e /boot xfs defaul
ts 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[root@localhost mytest]# more +/2017 fstab.test
 
...跳过

# /etc/fstab
# Created by anaconda on Tue May 30 06:31:44 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

/dev/mapper/cl-root / xfs defaults 0 0
UUID=8be7dbe5-dde6-40b0-8900-c30f1007287e /boot xfs defaul
ts 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[root@localhost mytest]# more +/4 fstab.test
 
...跳过
2
3
4
5

# /etc/fstab
# Created by anaconda on Tue May 30 06:31:44 2017

# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

/dev/mapper/cl-root / xfs defaults 0 0
UUID=8be7dbe5-dde6-40b0-8900-c30f1007287e /boot xfs defaul
ts 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[root@localhost mytest]# cat -n fstab.test | more
1 1
2 2
3 3
4 4
5 5
6
7
8
9
10
11 #
12 # /etc/fstab
13 # Created by anaconda on Tue May 30 06:31:44 2017
14 #
15 # Accessible filesystems, by reference, are maintained under '/dev/disk'
16 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
17 #
18 /dev/mapper/cl-root / xfs defaults 0 0
19 UUID=8be7dbe5-dde6-40b0-8900-c30f1007287e /boot xfs defaults 0 0
20 /dev/mapper/cl-swap swap swap defaults 0 0

less
  • image.png
  • 命令演示
    由于more命令查看大文件后,屏幕占用效果不是很好,就不再展示详细执行过程。

相关文章

  • linux文件查看类命令总结及演示

    head,tail,cat,more,less head image.png 命令演示[root@localhos...

  • Linux 下常用命令功能划分

    linux 常用命令 帮助类命令(2个) 文件和目录操作类命令(18个) 查看文件及内容处理命令(21个) 文件压...

  • linux基础(一)

    1.linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 有ls查看文件和目录、cd切换目录、...

  • 第二周

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 ls: list 功能:查看目录下文...

  • 文件管理命令

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 ls 功能:查看目录下文件的详细信息...

  • 176条DevOps人员常用的Linux命令速查表

    来自公众号:马哥Linux运维 线上查询及帮助命令 文件和目录操作命令 查看文件及内容处理命令 文件压缩及解压缩命...

  • 176条DevOps人员常用的Linux命令速查表

    来自公众号:马哥Linux运维 线上查询及帮助命令 文件和目录操作命令 查看文件及内容处理命令 文件压缩及解压缩命...

  • FHS、bash、用户权限及组管理

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 文件管理类命令主要包括:touch ...

  • 第二周作业

    壹--- Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示 1、Linux上的文件管理类命...

  • 1.28-2.3

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 文件管理类命令 cp: mv:移动或...

网友评论

      本文标题:linux文件查看类命令总结及演示

      本文链接:https://www.haomeiwen.com/subject/vywjdxtx.html