在 shellscript 裡面找出 process 的數目 - Linux

By Wallis
at 2015-05-21T22:36
at 2015-05-21T22:36
Table of Contents
我寫了一支 shellscript,叫做 test.sh,內容是:
#!/bin/bash
var=$(ps aux | grep 'test' )
echo $var
然後我執行的時候輸入 ./test.sh
結果輸出:
linux 7264 0.0 0.2 5180 1092 pts/0 S+ 22:33 0:00 /bin/bash ./test.sh
linux 7265 0.0 0.1 5180 512 pts/0 S+ 22:33 0:00 /bin/bash ./test.sh
linux 7267 0.0 0.1 4384 800 pts/0 S+ 22:33 0:00 grep test
如果把 shellscript 改成:
#!/bin/bash
ps aux | grep 'test'
會輸出:
linux 7271 0.0 0.2 5176 1096 pts/0 S+ 22:36 0:00 /bin/bash ./test.sh
linux 7273 0.0 0.1 4384 800 pts/0 S+ 22:36 0:00 grep test
想請問為何有這樣的差異呢 ?
--
Tags:
Linux
All Comments

By Sierra Rose
at 2015-05-22T00:39
at 2015-05-22T00:39

By Andrew
at 2015-05-24T05:07
at 2015-05-24T05:07

By Erin
at 2015-05-28T07:17
at 2015-05-28T07:17

By Olive
at 2015-06-01T04:26
at 2015-06-01T04:26
Related Posts
免費私有Git Repo - Visual Studio Online

By Jacky
at 2015-05-21T11:05
at 2015-05-21T11:05
Linux 下 WD My Passport 隨身硬碟加密問題(已解決)

By Thomas
at 2015-05-19T23:20
at 2015-05-19T23:20
Debian 套件打包工作坊

By Sandy
at 2015-05-19T19:30
at 2015-05-19T19:30
用pdf開啟文字檔 (轉檔問題)

By Megan
at 2015-05-19T15:45
at 2015-05-19T15:45
迴圈內變數中的變數問題?

By Edith
at 2015-05-18T22:50
at 2015-05-18T22:50