Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Facing issue with deleting few lines after a string match in a file including that line and previous line of the file match.

$
0
0

Consider a file with content like this :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<FileZilla3>

    <RecentServers>

   <Server>

   <Host>10.16.103.58</Host>

   <Port>22</Port>

   <Protocol>1</Protocol>

   <Type>0</Type>

   <User>mapfre</User>

   <Pass>Adelaide123?</Pass>

   <Logontype>1</Logontype>

   <TimezoneOffset>0</TimezoneOffset>

   <PasvMode>MODE_DEFAULT</PasvMode>

   <MaximumMultipleConnections>0</MaximumMultipleConnections>

   <EncodingType>Auto</EncodingType>

   <BypassProxy>0</BypassProxy>

</Server>

<xxxxxxx>

 

 

I want to match the string "<Host>10.16.103.58</Host>" and delete all lines till </server> and one line above the string match along with the current line. The final output should be like this 

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<FileZilla3>

    <RecentServers>

<xxxxxxx>

 

I am looking for a good solution asap. Can someone help me with this here ??

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles