作者 主題: 117-201 Question ask  (閱讀 4698 次)

0 會員 與 1 訪客 正在閱讀本文。

kainieh

  • 可愛的小學生
  • *
  • 文章數: 12
    • 檢視個人資料
117-201 Question ask
« 於: 2005-10-30 11:35 »
You need to use grep to search for specific log entries. Given the following three log entries, which grep
command will match only one line? Assume that every pattern matches at least one line.
Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
A. grep "hostname\ [^\]*\[A-Z]*:"
B. grep "Ju[I-Z]\[0-9].*:.1"
C. grep "hostname,*[pumpd]*[10]"
D. grep "[0-9]:[1-8]*\ host.*\(.*\)"
E. grep "US*[^]]*]*:"
Answer: D.

Please help for "Why"

Ryan_Hsieh

  • 可愛的小學生
  • *
  • 文章數: 1
    • 檢視個人資料
Re: 117-201 Question ask
« 回覆 #1 於: 2005-12-25 04:54 »
引用

Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
A. grep "hostname\ [^\]*\[A-Z]*:"

因資料行中無一行中括號內有英文字母,故無一符合!
引用

Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
B. grep "Ju[I-Z]\[0-9].*:.1"

月份只有第一個字母大寫,且其後跟著是空格!
引用

Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
C. grep "hostname,*[pumpd]*[10]"

hostname後面跟著的都是空格!
引用

Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
D. grep "[0-9]:[1-8]*\ host.*\(.*\)"

符合的時間資料行後面跟的是hostname而非空格!
引用

Jun 16 01:46:18hostname pumpd[10]: PUMP: got an offer
Jun 17 21:52:28hostname kernel: SCSI subsystem driver Revision: 1.00
Jul 20 11:09:01hostname /USR/SBIN/CRON[1800]: (mail) CMD runq
E. grep "US*[^]]*]*:"

有一個大寫的U均符合!