使用bash工具我需要一些帮助
原文链接:https://www.f2er.com/bash/385230.html<CreateOfficeCode> <OperatorId>ve</OperatorId> <OfficeCode>1234</OfficeCode> <CountryCodeLength>0</CountryCodeLength> <AreaCodeLength>3</AreaCodeLength> <Attributes></Attributes> <ChargeArea></ChargeArea> </CreateOfficeCode>
成为:
<CreateOfficeCode> <OperatorId>ve</OperatorId> <OfficeCode>1234</OfficeCode> <CountryCodeLength>0</CountryCodeLength> <AreaCodeLength>3</AreaCodeLength> </CreateOfficeCode>
为此我通过这个命令这样做了
sed -i '/><\//d' file
这不是那么严格,更像是一个技巧,更合适的是找到< pattern>< / pattern>并删除它.建议?
>其次,如何从:
<CreateOfficeGroup> <CreateOfficeName>John</CreateOfficeName> <CreateOfficeCode> </CreateOfficeCode> </CreateOfficeGroup>
至:
<CreateOfficeGroup> <CreateOfficeName>John</CreateOfficeName> </CreateOfficeGroup>
>作为一个整体?从:
<CreateOfficeGroup> <CreateOfficeName>John</CreateOfficeName> <CreateOfficeCode> <OperatorId>ve</OperatorId> <OfficeCode>1234</OfficeCode> <CountryCodeLength>0</CountryCodeLength> <AreaCodeLength>3</AreaCodeLength> <Attributes></Attributes> <ChargeArea></ChargeArea> </CreateOfficeCode> <CreateOfficeSize> <Chairs></Chairs> <Tables></Tables> </CreateOfficeSize> </CreateOfficeGroup>
至:
<CreateOfficeGroup> <CreateOfficeName>John</CreateOfficeName> <CreateOfficeCode> <OperatorId>ve</OperatorId> <OfficeCode>1234</OfficeCode> <CountryCodeLength>0</CountryCodeLength> <AreaCodeLength>3</AreaCodeLength> </CreateOfficeCode> </CreateOfficeGroup>
你能否回答个人问题?非常感谢你!