shell输入/输出重定向

不羁岁月 提交于 2019-11-28 20:03:08

command > file:将输出重定向到file

command >> file:将输出以追加的方式重定向到file

说明:上述命令的意思是执行command然后将输出的内容存入到file(覆盖还是追加由> 和 >> 决定)

[root@ipha-dev71-1 exercise_shell]# echo 1 > test.sh 
[root@ipha-dev71-1 exercise_shell]# cat test.sh   # 查看文件内容
1
[root@ipha-dev71-1 exercise_shell]# echo 2 >test.sh 
[root@ipha-dev71-1 exercise_shell]# cat test.sh   
2
[root@ipha-dev71-1 exercise_shell]# echo 3 >> test.sh 
[root@ipha-dev71-1 exercise_shell]# cat test.sh 
2
3

command < file:将输入重定向到file

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!