Created
June 13, 2019 09:34
-
-
Save thecfguy/1d964b68912cb9210515c2f142ea0ed8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Powershell script to list all files (including sub directory) under particular directory and remove last line out of it. | |
Get-ChildItem ".\" -Recurse -Filter *.txt | | |
Foreach-Object { | |
$lastline = Get-Content $_.FullName | select -Last 1 | |
if ($lastline -like 'findsomestring') { | |
$test = Get-Content $_.FullName | |
$output = $test[0..($test.count - 2)] | |
Set-Content -Path $_.FullName -Value $output | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment