sneha
sneha

Reputation: 187

how can i parse a yaml file from a linux shell script

I have my YAML file as below:

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

I wanted to parse my YAML file using shell script and wanted the answer as:

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

Upvotes: 1

Views: 3103

Answers (1)

jijinp
jijinp

Reputation: 2662

sed '/columns:/d;s/^\s*-\s*//g' file.yml

Upvotes: 1

Related Questions