linux的重定向管道与环境变量PATH
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux的重定向管道与环境变量PATH相关的知识,希望对你有一定的参考价值。
(文章目录)
一、重定向
1.输出重定向:>
1.写入指定文件
[root@VM-8-8-centos lesson5]# cat file.txt
[root@VM-8-8-centos lesson5]# echo "hello world" > file.txt
[root@VM-8-8-centos lesson5]# cat file.txt
hello world
[root@VM-8-8-centos lesson5]# cat file.txt > test.c
[root@VM-8-8-centos lesson5]# cat test.c
hello world
2. 覆盖写
[root@VM-8-8-centos lesson5]# cat file.txt
hello world
[root@VM-8-8-centos lesson5]# echo "you can see you" > file.txt
[root@VM-8-8-centos lesson5]# cat file.txt
you can see you
2.追加重定向 :>>
[root@VM-8-8-centos lesson5]# echo "you can see you" > file.txt
[root@VM-8-8-centos lesson5]# cat file.txt
you can see you
[root@VM-8-8-centos lesson5]# echo "you can see me" >> file.txt
[root@VM-8-8-centos lesson5]# cat file.txt
you can see you
you can see me
[root@VM-8-8-centos lesson5]# echo "you can see me" >> file.txt
[root@VM-8-8-centos lesson5]# cat file.txt
you can see you
you can see me
you can see me
3.输出重定向:<
1.键盘显示
[root@VM-8-8-centos lesson5]# cat
abcdefhgjkl
abcdefhgjkl
2.文件显示
```c
[root@VM-8-8-centos lesson5]# cat < file.txt
you can see you
you can see me
you can see me
[root@VM-8-8-centos lesson5]# cat file.txt
you can see you
you can see me
you can see me
4.重定向的一些认知误区
1. test.c只显示错误的
find /home -name test.c > msg.c
2. msg.c只显示正确的
3.分析
4.显示出正确的
二、管道
last指令
1.前五行数据的查询
[root@VM-8-8-centos ~]# last | head -5
root pts/1 103.57.12.38 Mon Oct 3 16:16 still logged in
root pts/0 106.41.249.118 Mon Oct 3 15:19 still logged in
root pts/0 103.57.12.38 Sun Oct 2 18:13 - 19:42 (01:29)
root pts/1 106.41.249.15 Sat Oct 1 14:09 - 15:59 (01:50)
root pts/0 103.57.12.38 Sat Oct 1 13:24 - 14:22 (00:58)
1.用户登录次数
[root@VM-8-8-centos ~]# last | grep root | wc -l
45
三、环境变量PATH
1.判断自己写的与系统的命令是否一致
2.环境变量 PATH
1.环境变量 PATH概念
2.查看环境变量
3.修改自己写的拷贝到 PATH中
2.当前路径添加到环境变量中
以上是关于linux的重定向管道与环境变量PATH的主要内容,如果未能解决你的问题,请参考以下文章