Shell 重定向Redirection的應用

Other useful command:

1.       nm –list symbols from object files

2.       ar crv libfoo.a bill.o foo.o

gcc –o hello hello.c libfoo.a

or gcc –o hello hello.c –L. –lfoo

 

 

Redirect:

Redirecting output:

 $ls –al > output.txt (if output.txt exist: overwriting the output.txt

$ls –al >> output.txt(if output.txt exist, append the output.text)

$ kill -HUP 1234 >killout.txt 2>killerr.txt (will put the output and error information into separate files.)

$ kill -1 1234 >killouterr.txt 2>&1(f you prefer to capture both sets of output into a single file, you can use the >& operator to combine the two outputs. Therefore,)

$ kill -1 1234 >/dev/null 2>&1 (you don’t often want to save either standard output or standard error. You can use the Linux universal “bit bucket” of /dev/null to efficiently discard the entire output, like this:)

Redirecting input:

Rather like redirecting output, you can also redirect input. For example,

$ more < killout.txt

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章