Add text to every line in text file using PowerShell

最后都变了- 提交于 2019-12-01 15:04:27

Soemthing like this should work:

function append-text { 
  process{
   foreach-object {$_ + "*"}
    } 
  }
Elroy Flynn

No function necessary. This would do it:

$b|foreach {$_ +  "*"}
PS> (gc c:\foobar.txt) -replace '\S+$','$&*'
Sam Skidmore

Simply took about 2 hours to work it out, had never used Powershell before, but here you go:

cls
#Define Functions
(gc g:\foobar.txt) -replace '\S+$','$& 1GB RAM 1x 1 GB Stick' | out-file "g:\ram 6400s.txt"

Change the file location. First file is the file you want to edit. The secound one is the output file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!