我有一个定义明确的问题,似乎是 sed 的一个很好的候选者。
我的输入文件包含两个标记之一:
[FILE]
或者[LINE]
结构如下所示:
[FILE]: C:\Users\user\git\build.xml
[FILE]: C:\Users\user\git\dataload-pom.xml
[FILE]: C:\Users\user\git\local.properties
[LINE]: [job.mail.toAddress=]
[LINE]: [log.mail.toAddress=]
[LINE]: [log.mail.client.toAddress=]
[LINE]: [log.mail.toAddress=]
[LINE]: [bill.report.toAddress=]
[FILE]: C:\Users\user\git\pom.xml
[FILE]: C:\Users\user\git\release.properties
[LINE]: [job.mail.toAddress=]
[LINE]: [log.mail.client.toAddress=]
预期的输出将是:
[FILE]: C:\Users\user\git\local.properties
[LINE]: [job.mail.toAddress=]
[LINE]: [log.mail.toAddress=]
[LINE]: [log.mail.client.toAddress=]
[LINE]: [log.mail.toAddress=]
[LINE]: [bill.report.toAddress=]
[FILE]: C:\Users\user\git\release.properties
[LINE]: [job.mail.toAddress=]
[LINE]: [log.mail.client.toAddress=]
如果文件名有与之关联的行,我只想查看它们。我是 sed 的新手,希望完全了解您的工作。