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

How do I trim a line in a .txt file and append the result in the same file.

$
0
0

I have a .txt file of the following structure:

 

License Applied to NGP Application Server:\\qafile2\Leonardo\Feature Data\License 2.0\LossUI\Asia\Licenses\TOUCHSTONE\LossAustralia10K-EQ-PP\Air.TOUCHSTONE.xml 

(next line with content)

. (next line with content)

.(next line with content)

License Applied to NGP Application Server:\\qafile2\Leonardo\Feature Data\License 2.0\LossUI\Asia\Licenses\TOUCHSTONE\LossAustralia10K-TC-PP\Air.TOUCHSTONE.xml

.... (and so on)

 

The parts of the txt file that contains"License Applied to NGP Application Server:\\qafile2\Leonardo\Feature Data\License 2.0\LossUI\Asia\Licenses\TOUCHSTONE\LossAustralia10K-EQ-PP\Air.TOUCHSTONE.xml "   is a single line and occurs every few lines at atleast 200 times within the txt file. 

I want to trim this line to only contain the bolded part, i.e. "LossAustralia10K-EQ-PP" and want to remove the parts before and after it on that line and update this on the same file, i.e. I only want LossAustralia10K-EQ-PP to be present instead of the whole line "License Applied to NGP Application Server:\\qafile2\Leonardo\Feature Data\License 2.0\LossUI\Asia\Licenses\TOUCHSTONE\LossAustralia10K-EQ-PP\Air.TOUCHSTONE.xml". 

The continent name is not always the same, i.e. one line cud have LossAustralia, the next recurring line with the same pattern may have LossAsia.

 

Any help will be appreciated.

 


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images