一、重定向
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]# 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
把file.txt文件的内容 you can see me 打印后,
使用 >> 发现会在文件结尾 追加内容。
3.输入重定向:<
```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
cat < file.txt 与 cat file.txt等价
cat < file.txt :从fille.txt文件中读取数据
二 、xshell命令及原理
用户并不是直接访问操作系统,而是通过外壳程序
外壳程序通过指令的方式收到,外壳程序把收到的指令传递给操作系统 操作系统进行处理,执行完后 再通过shell 返回给用户