看板 Linux 關於我們 聯絡資訊
test="[ro.serialno]: [D6GQHIOZTKMBOZJR]" echo $test | sed 's/.*\[\(.*\)\].*\[\(.*\)\].*/\2/g' 後面的‘\2’表示取第二個括號的值 D6GQHIOZTKMBOZJR 如果一個字串是 test="(ro.serialno): (D6GQHIOZTKMBOZJR)" 要如何用上面sed方式取出()內的字串呢?謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.44.52.220 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1559146066.A.778.html
CP64: 就... 把 \[ \] 換成 ( ) 05/30 00:35
goldie: s/.*(\([^()]*\)): (\([^()]*\)).*/\2/ 05/30 00:39
Gold740716: grep -o '([^()]*)' 06/12 19:25