Linux中的重定向

Linux中的重定向操作

1.输出重定向:

Command > filename:把标准输出重定向到一个新文件中,当filename不存在时
Command >> filename:把标准输出重定向到一个文件中(追加)
Command > filename 2>&1:把标准输出和错误一起重定向到一个文件中
Command >> filename 2>&1:把标准输出和错误一起重定向到一个文件(追加)
Command 2 > filename:把标准错误重定向到一个文件中
Command 2 >> filename:把标准输出重定向到一个文件中(追加)
示例:

[root@localhost ~]# ll
total 2440
drwxr-xr-x.  4 root root    4096 Apr  4 09:50 hadoop_temp
drwxr-xr-x.  8 root root    4096 May  6 04:30 IdeaProjects
[root@localhost ~]# echo HelloLinux > HelloLinux.txt
[root@localhost ~]# ll
total 2444
drwxr-xr-x.  4 root root    4096 Apr  4 09:50 hadoop_temp
-rw-r--r--.  1 root root      11 Jun 16 05:26 HelloLinux.txt
drwxr-xr-x.  8 root root    4096 May  6 04:30 IdeaProjects
[root@localhost ~]# cat HelloLinux.txt 
HelloLinux
[root@localhost ~]# 

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/80713732