ファイルを解析して特定のフィールドを抽出する必要があります。
サンプルファイル形式:
"make":"honda","group":"xyz","model":"accord","year":"2007","miles":"67000"
"make":"honda","group":"abc","model":"civic","year":"2011","miles":"40000"
"make":"toyota","group":"abc","model":"camry","year":"2011","miles":"40000"
"make":"toyota","color":"black","group":"hgh","model":"camry","year":"2015","miles":"2000"
"make":"lincoln","color":"silver","group":"ugh","model":"MKZ","year":"2013","miles":"20000"
モデルとマイレージの下のフィールドを抽出し、別のファイルに書き込む必要があります。上記では、次の抜粋が必要です。
accord:67000
civic:40000
camry:40000
camry:2000
MKZ:20000
答え1
awkを使用してください:
awk -F'[:,]' '{gsub(/"/,""); printf "%s:%s\n", $(NF-4),$NF}' file
accord:67000
civic:40000
camry:40000
camry:2000
MKZ:20000