for example:
[lee@bogon test]$ mkdir test
[lee@bogon test]$ cd test/
[lee@bogon test]$ vi a.txt
[lee@bogon test]$ ls
a.txt
[lee@bogon test]$ ls a.txt b.txt
ls: cannot access b.txt: No such file or directory
a.txt
提示错误,实际上是strandard error,下面重定向到文件中。
[lee@bogon test]$ ls a.txt b.txt 1>file.out 2>file.err
[lee@bogon test]$ cat file.err
ls: cannot access b.txt: No such file or directory
[lee@bogon test]$ ls a.txt b.txt 1>file.out 2>&1
[lee@bogon test]$ cat file.out
ls: cannot access b.txt: No such file or directory
a.txt
[lee@bogon test]$ ls a.txt b.txt 2>file.err 1>&2
[lee@bogon test]$ cat file.err
ls: cannot access b.txt: No such file or directory
a.txt
[lee@bogon test]$ cat hello.txt
1 A fall into a pit,a gain in your wit.
8 A fox may grow gray,but never good.
[lee@bogon test]$ cat hello.txt | awk '$1 < 5 {print $1 "\t" $3}'
1 fall
[lee@bogon test]$ cat hello.txt | awk '$1 < 9 {print $1 "\t" $3}'
1 fall
8 fox
$1 < 5为条件,第一个参数小于5,则打印出来
条件也可以省去,直接打印内容
for example:
[lee@bogon test]$ cat hello.txt | awk '{print $1 "\t" $3}'
1 fall
8 fox