第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

更加優(yōu)雅的“ ps aux | grep -v grep”

更加優(yōu)雅的“ ps aux | grep -v grep”

尚方寶劍之說(shuō) 2019-10-24 11:17:39
當(dāng)我檢查過(guò)程列表并“ grep”出對(duì)我來(lái)說(shuō)很有趣的過(guò)程時(shí),其grep本身也包含在結(jié)果中。例如,列出終端:$ ps aux  | grep terminaluser  2064  0.0  0.6 181452 26460 ?        Sl   Feb13   5:41 gnome-terminal --working-directory=..user  2979  0.0  0.0   4192   796 pts/3    S+   11:07   0:00 grep --color=auto terminal通常我ps aux | grep something | grep -v grep用來(lái)擺脫最后一個(gè)條目...但是它并不優(yōu)雅 :)您是否有更優(yōu)雅的技巧來(lái)解決此問(wèn)題(將所有命令包裝到單獨(dú)的腳本中,這也不錯(cuò))
查看完整描述

3 回答

?
拉風(fēng)的咖菲貓

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊

通常的技術(shù)是這樣的:


ps aux | egrep '[t]erminal'

這將匹配包含的行terminal,但egrep '[t]erminal'不匹配!它也可以在許多 Unix版本上使用。


查看完整回答
反對(duì) 回復(fù) 2019-10-24
?
交互式愛(ài)情

TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊

該答案基于先前的pgrep 答案。它還建立在另一個(gè)答案結(jié)合使用的ps與pgrep。以下是一些相關(guān)的培訓(xùn)示例:


$ pgrep -lf sshd

1902 sshd


$ pgrep -f sshd

1902


$ ps up $(pgrep -f sshd)

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root      1902  0.0  0.1  82560  3580 ?        Ss   Oct20   0:00 /usr/sbin/sshd -D


$ ps up $(pgrep -f sshddd)

error: list of process IDs must follow p

[stderr output truncated]


$ ps up $(pgrep -f sshddd) 2>&-

[no output]

以上可以用作功能:


$ psgrep() { ps up $(pgrep -f $@) 2>&-; }


$ psgrep sshd

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root      1902  0.0  0.1  82560  3580 ?        Ss   Oct20   0:00 /usr/sbin/sshd -D

用比較ps有g(shù)rep。不會(huì)打印出有用的標(biāo)題行:


$  ps aux | grep [s]shd

root      1902  0.0  0.1  82560  3580 ?        Ss   Oct20   0:00 /usr/sbin/sshd -D


查看完整回答
反對(duì) 回復(fù) 2019-10-24
?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

另一種選擇:


ps -fC terminal

這里的選項(xiàng):


 -f        does full-format listing. This option can be combined

           with many other UNIX-style options to add additional

           columns. It also causes the command arguments to be

           printed. When used with -L, the NLWP (number of

           threads) and LWP (thread ID) columns will be added. See

           the c option, the format keyword args, and the format

           keyword comm.


 -C cmdlist     Select by command name.

                This selects the processes whose executable name is

                given in cmdlist.


查看完整回答
反對(duì) 回復(fù) 2019-10-24
  • 3 回答
  • 0 關(guān)注
  • 1323 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)