我想从格式(主机名,,)的网络组中提取主机名。我使用了以下 sed 命令。似乎它们都不起作用。谁能指出我正确的正则表达式构造?谢谢。
bash-3.2# ypcat -k netgroup|grep '^gridprod2 '|sed 's/(\([a-zA-Z0-9]*\),,)/\1\n/g'
gridprod2 (sbpsvrso766,,) (sbpsvrso767,,) (sbpsvrso768,,) (sbpsvrso769,,) (sbpsvrso461,,) (sbpsvrso462,,) (sbpsvrso463,,) (sbpsvrso464,,) (sbpsvrso465,,) (sbpsvrso466,,) (sbpsvrso467,,) (sbpsvrso468,,) (sbtorsvr569,,) (sbpsvrwm841,,) (sbpsvrwm842,,) (sbpsvrwm843,,) (sbpsvrwm844,,) (sbpsvrwm845,,) (sdpsvrso804,,)
bash-3.2# ypcat -k netgroup|grep '^gridprod2 '|sed 's/(\([:alnum:]*\),,)/\1\n/g'
gridprod2 (sbpsvrso766,,) (sbpsvrso767,,) (sbpsvrso768,,) (sbpsvrso769,,) (sbpsvrso461,,) (sbpsvrso462,,) (sbpsvrso463,,) (sbpsvrso464,,) (sbpsvrso465,,) (sbpsvrso466,,) (sbpsvrso467,,) (sbpsvrso468,,) (sbtorsvr569,,) (sbpsvrwm841,,) (sbpsvrwm842,,) (sbpsvrwm843,,) (sbpsvrwm844,,) (sbpsvrwm845,,) (sdpsvrso804,,)