我的YAML文件如下:
report_id: demographics
columns:
- date
- channel_id
- video_id
- claimed_status
- uploader_type
- live_or_on_demand
report_id: device_os
columns:
- date
- channel_id
- video_id
- asset_id
- claimed_status
- uploader_type
- live_or_on_demand
- subscribed_status
- country_code
- device_type
- operating_system
我想使用shell脚本解析我的YAML文件,并希望答案为:
report_id: demographics
date
channel_id
video_id
claimed_status
uploader_type
live_or_on_demand
report_id: device_os
date
channel_id
video_id
asset_id
claimed_status
uploader_type
live_or_on_demand
subscribed_status
country_code
device_type
operating_system
答案 0 :(得分:1)
sed '/columns:/d;s/^\s*-\s*//g' file.yml