I'm trying to compare two yml
files and removing a block based on some conditions using shell script. I'm using this YML
parser, https://gist.github.com/pkuczynski/8665367 for the comparison of yml
files. But I'm really strugglig a lot for removing the block from them. For example,
tool:
image: tool.xxx.com/platform/app:dev
log_driver: syslog
restart: always
ports:
- "54325:80"
- "543325:80"
volume:
- "a:b"
tool1:
image: tool1.xxx.com/platform/app:dev
log_driver: syslog
restart: always
ports:
- "54325:80"
- "543325:80"
volume:
- "a:b"
How to remove ports block under tool
and which will make output similar to,
tool:
image: tool.xxx.com/platform/app:dev
log_driver: syslog
restart: always
volume:
- "a:b"
tool1:
image: tool1.xxx.com/platform/app:dev
log_driver: syslog
restart: always
ports:
- "54325:80"
- "543325:80"
volume:
- "a:b"
I tried somethings using awk and sed, but I don't know exactly as it contains some complex condition involving multiple lines.
Any help or suggestion on this would be greatly helpful and much appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…