ksh環境のファイルから部分文字列を抽出する

ksh環境のファイルから部分文字列を抽出する

以下のエラーメッセージを含むファイルがあります。

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1505) 
rsync error: error in rsync protocol data stream (code 12) at token.c(604)

たとえば、最初の行では23、2行目では12などのコード番号を抽出したいと思います。

ベストアンサー1

良い

$ grep -o "(code [0-9]*" file | cut -d" " -f2
23
12

おすすめ記事