Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. gc c:FileWithEmptyLines.txt | where {$_ -ne ""} > c:FileWithNoEmptyLines.txt
  2.  
  3. (gc file.txt) | ? {$_.trim() -ne "" } | set-content file.txt
  4.  
  5. @(gc c:FileWithEmptyLines.txt) -match 'S' | out-file c:FileWithNoEmptyLines
  6.  
  7. PS C:Users> (gc file.txt) | Foreach {$_.TrimEnd()} | where {$_ -ne ""} | Set-Content file.txt
  8.  
  9. (Get-Content c:FileWithEmptyLines.txt) |
  10. Foreach { $_ -Replace "Old content", " New content" } |
  11. Set-Content c:FileWithEmptyLines.txt;
  12.  
  13. [IO.File]::ReadAllText("FileWithEmptyLines.txt") -replace 's+rn+', "`r`n" | Out-File "c:FileWithNoEmptyLines.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement