文章目錄
- 輸出重定向
-
- 1. 标準輸入輸出
- 2. 輸出重定向
- 3.輸入重定向
輸出重定向
1. 标準輸入輸出
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsICM38FdsYkRGZkRG9lcvx2bjxiNx8VZ6l2csgWNXR2cshUZs50MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLwcTO2ETMwEjM5ADOwkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
2. 輸出重定向
示例:
[[email protected] ~]$ ll
total 8
-rw-rw-r-- 1 cds cds 129 Aug 9 20:14 a.txt
-rw-rw-r-- 1 cds cds 96 Aug 9 21:06 b.txt
[[email protected] ~]$ ll > b.txt
[[email protected] ~]$ cat b.txt
total 4
-rw-rw-r-- 1 cds cds 129 Aug 9 20:14 a.txt
-rw-rw-r-- 1 cds cds 0 Aug 9 21:06 b.txt
[[email protected] ~]$ ls
a.txt b.txt
[[email protected] ~]$ ls >> b.txt
[[email protected] ~]$ cat b.txt
total 4
-rw-rw-r-- 1 cds cds 129 Aug 9 20:14 a.txt
-rw-rw-r-- 1 cds cds 0 Aug 9 21:06 b.txt
a.txt
b.txt
[[email protected] ~]$ lsdf 2>> b.txt
[[email protected] ~]$ cat b.txt
total 4
-rw-rw-r-- 1 cds cds 129 Aug 9 20:14 a.txt
-rw-rw-r-- 1 cds cds 0 Aug 9 21:06 b.txt
a.txt
b.txt
bash: lsdf: command not found...
- 上面的内容是為了引出下面這些内容
- 丢到垃圾桶
-
ls &>/dev/null
3.輸入重定向
[[email protected] ~]$ wc < a.txt
9 6 129
[[email protected] ~]$ wc << end
> adfa
> dfdskjf
> dfds
> end
3 3 18