Parsing .ini file in bash
问题 I have a below properties file and would like to parse it as mentioned below. Please help in doing this. .ini file which I created : [Machine1] app=version1 [Machine2] app=version1 app=version2 [Machine3] app=version1 app=version3 I am looking for a solution in which ini file should be parsed like [Machine1]app = version1 [Machine2]app = version1 [Machine2]app = version2 [Machine3]app = version1 [Machine3]app = version3 Thanks. 回答1: Try: $ awk '/\[/{prefix=$0; next} $1{print prefix $0}' file