文章目录
一、重定向
定义:将前面命令的输出,作为内容,写入到后面的文件
1.  >:覆盖重定项 ,会把后面写入文件的本身内容覆盖
2.  >>:追加重定向,会到目标文件的末尾新增加写入的内容
 
二、管道(操作符号 | )
作用:将前面命令的输出,传递给后面命令。作为后面命令的参数
 
[root@host50 ~]# head  -4  /etc/passwd   |      tail  -1
adm:x:3:4:adm:/var/adm:/sbin/nologin
 
解释:查找/etc/passwd前4行的最后一行内容
[root@host50 ~]#  cat -n  /etc/passwd  |  head -8  |   tail  -1
8	halt:x:7:0:halt:/sbin:/sbin/halt
 
解释:cat -n 代表查看时显示查看行的行号
三.grep高级使用
作用:从文本文件内容中,过滤掉关键字符
 
 [root@host50 ~]#  grep  root  /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
 
-v 取反匹配
[root@host50 ~]#  grep  root  /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
 
^root 以root开头进行匹配
[root@host50 ~]# grep  ^root  /etc/passwd  #以root开头
root:x:0:0:root:/root:/bin/bash
 
bash$ 以bash结尾进行匹配
[root@host50 ~]# grep  bash$  /etc/passwd
root:x:0:0:root:/root:/bin/bash
 
^$:表示空行
 Linux中大多数配置文件内容,以#开头的行为注释行










