I can trim all contents in a file
$lines=(Get-Content $BaselineFile) foreach ($line in $lines) { $line= $line.Trim() }
But how to return the result to the same file. ($ Baselinefile)
Here is a good 2 liner:
$lines=(Get-Content $BaselineFile) | foreach{ $_.Trim()} $lines > $BaselineFile
This is more concise:
(gc $BaseLineFile)| % {$_.trim()} | sc $BaseLineFile
$lines=(Get-Content $BaselineFile) $newcontent = foreach ($line in $lines) { $line.Trim()} $newcontent | out-file $BaselineFile
Source: https://habr.com/ru/post/1389632/More articles:How to redirect from login action if session for user role is ready to install in symfony 2 - securityTomcat - SEVERE Error starting static resources (war that was purposely deleted) - tomcatNo connection can be made because the target machine actively rejected it 127.0.0.1:8000 - c #JS, jQuery plugin with smooth calendar effect - javascriptBufferedImage.getSubimage Method Guide (int x, int y, int w, int h)? - javaJPA2 + Hibernate 4: removing orphans (orphanRemoval = true) does not work with OneToOne - hibernateWhich browsers currently implement HTML5 MediaController support? - cross-browserAvoid inserting duplicate rows in mySQL - databaseRemoving localhost url in asp mvc - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1389637/sending-files-to-a-webservice-asmx-so-it-can-be-saved-on-the-server&usg=ALkJrhhtaU3mXPL1zTtwps3XN2lD7opJBgAll Articles