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

Delete specific range of lines from a file

$
0
0

Hi there,

   I have a text file (temp.txt) that gets populated as a result of running a specific query. 

$x and $y are dynamically assigned values based on some calculations

then i check

if( $numlinesinfile -ne ($x+$y))

{ Write-Host -ForegroundColor Magenta "Error..."

//I want to delete lines from 2 to end of file and just retaining the header}

else

{Write-Host "Finished.."-ForegroundColor DarkBlue}

 

Is this possible?

  Thanks

Rashm


Viewing all articles
Browse latest Browse all 6937

Trending Articles