close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_fs.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Jul 4, 2009, 11:27:43 AM (17 years ago)
- Author:
-
jazz
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
v8
|
v9
|
|
| 88 | 88 | * 使用 << EOF 來一次輸入很多資料 |
| 89 | 89 | {{{ |
| 90 | | ubuntu@ubuntu:~$ cat > file9 << EOF |
| 91 | | this is a test |
| 92 | | 使用 << EOF 來一次輸入很多資料 |
| | 90 | ubuntu@ubuntu:~$ cat > cat-test.txt << EOF |
| | 91 | aaa1 |
| | 92 | bbb2 |
| | 93 | ccc3 |
| | 94 | |
| | 95 | ddd4 |
| | 96 | eee5 |
| | 97 | |
| | 98 | |
| | 99 | fff6 |
| | 100 | ggg7 |
| | 101 | |
| 93 | 102 | EOF |
| 94 | | ubuntu@ubuntu:~$ cat file9 |
| 95 | | this is a test |
| 96 | | 使用 << EOF 來一次輸入很多資料 |
| 97 | 103 | }}} |
| 98 | 104 | * 重新導向到 /dev/null 就不會顯示了 |
| … |
… |
|
| 100 | 106 | ubuntu@ubuntu:~$ ls temp temp2 > /dev/null 2>&1 |
| 101 | 107 | }}} |
| | 108 | |
| | 109 | = 2. pipe 管路 = |
| | 110 | |
| | 111 | * 有時候需要透過好幾個指令把 STDIN 跟 STDOUT 串在一起,就可以很快找出想要的資訊。 |
| | 112 | {{{ |
| | 113 | ubuntu@ubuntu:~$ echo "file" |
| | 114 | file |
| | 115 | ubuntu@ubuntu:~$ echo "file" | cat |
| | 116 | file |
| | 117 | ubuntu@ubuntu:~$ cat cat-test.txt | sort -n |
| | 118 | |
| | 119 | |
| | 120 | |
| | 121 | aaa1 |
| | 122 | bbb2 |
| | 123 | ccc3 |
| | 124 | ddd4 |
| | 125 | eee5 |
| | 126 | fff6 |
| | 127 | ggg7 |
| | 128 | }}} |
| | 129 | * wc 指令可以拿來統計字數,這裡代表總共有 11 行,7個非空白行,總字數為 39 (包含換行符號) |
| | 130 | {{{ |
| | 131 | ubuntu@ubuntu:~$ cat cat-test.txt | wc |
| | 132 | 11 7 39 |
| | 133 | }}} |
| | 134 | * nl 指令可以拿來統計行號 |
| | 135 | {{{ |
| | 136 | |
| | 137 | }}} |