sed取指定字串中的特定子字串 - Linux

By Noah
at 2019-05-30T00:07
at 2019-05-30T00:07
Table of Contents
test="[ro.serialno]: [D6GQHIOZTKMBOZJR]"
echo $test | sed 's/.*\[\(.*\)\].*\[\(.*\)\].*/\2/g'
後面的‘\2’表示取第二個括號的值
D6GQHIOZTKMBOZJR
如果一個字串是
test="(ro.serialno): (D6GQHIOZTKMBOZJR)"
要如何用上面sed方式取出()內的字串呢?謝謝
--
echo $test | sed 's/.*\[\(.*\)\].*\[\(.*\)\].*/\2/g'
後面的‘\2’表示取第二個括號的值
D6GQHIOZTKMBOZJR
如果一個字串是
test="(ro.serialno): (D6GQHIOZTKMBOZJR)"
要如何用上面sed方式取出()內的字串呢?謝謝
--
Tags:
Linux
All Comments

By Candice
at 2019-05-31T20:04
at 2019-05-31T20:04

By Andrew
at 2019-06-01T19:50
at 2019-06-01T19:50

By George
at 2019-06-06T07:29
at 2019-06-06T07:29
Related Posts
老電腦進桌面前要先亂按鍵盤

By Leila
at 2019-05-26T21:01
at 2019-05-26T21:01
Manjaro Linux 安裝問題...請教

By Candice
at 2019-05-25T13:49
at 2019-05-25T13:49
docker安裝shadowsocks-libev如何產生log

By Cara
at 2019-05-24T15:40
at 2019-05-24T15:40
hime 輸入法在manjaro出不來

By Joe
at 2019-05-23T10:57
at 2019-05-23T10:57
螢幕無法休眠

By Regina
at 2019-05-22T21:57
at 2019-05-22T21:57