Changes between Version 8 and Version 9 of YM_Course_2009/Lab4


Ignore:
Timestamp:
Jul 4, 2009, 11:27:43 AM (15 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YM_Course_2009/Lab4

    v8 v9  
    8888 * 使用 << EOF 來一次輸入很多資料
    8989{{{
    90 ubuntu@ubuntu:~$ cat > file9 << EOF
    91 this is a test
    92 使用 << EOF 來一次輸入很多資料
     90ubuntu@ubuntu:~$ cat > cat-test.txt << EOF
     91aaa1
     92bbb2
     93ccc3
     94
     95ddd4
     96eee5
     97
     98
     99fff6
     100ggg7
     101
    93102EOF
    94 ubuntu@ubuntu:~$ cat file9
    95 this is a test
    96 使用 << EOF 來一次輸入很多資料
    97103}}}
    98104 * 重新導向到 /dev/null 就不會顯示了
     
    100106ubuntu@ubuntu:~$ ls temp temp2 > /dev/null 2>&1
    101107}}}
     108
     109= 2. pipe 管路 =
     110
     111 * 有時候需要透過好幾個指令把 STDIN 跟 STDOUT 串在一起,就可以很快找出想要的資訊。
     112{{{
     113ubuntu@ubuntu:~$ echo "file"
     114file
     115ubuntu@ubuntu:~$ echo "file" | cat
     116file
     117ubuntu@ubuntu:~$ cat cat-test.txt | sort -n
     118
     119
     120
     121aaa1
     122bbb2
     123ccc3
     124ddd4
     125eee5
     126fff6
     127ggg7
     128}}}
     129 * wc 指令可以拿來統計字數,這裡代表總共有 11 行,7個非空白行,總字數為 39 (包含換行符號)
     130{{{
     131ubuntu@ubuntu:~$ cat cat-test.txt | wc
     132     11       7      39
     133}}}
     134 * nl 指令可以拿來統計行號
     135{{{
     136
     137}}}