使用 PowerShell 将文本添加到文本文件中的每一行 [英] Add text to every line in text file using PowerShell
本文介绍了使用 PowerShell 将文本添加到文本文件中的每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 .txt 文档中每行文本的末尾添加字符.
I'd like to add characters to the end of every line of text in a .txt document.
#Define Variables
$a = c:\foobar.txt
$b = get-content $a
#Define Functions
function append-text
{
foreach-Object
{
add "*"
}
}
#Process Code
$b | append-text
类似的东西.本质上,加载给定的文本文件,在该文本文件的每一行文本的末尾添加一个*",保存并关闭.
Something like that. Essentially, load a given text file, add a "*" the the end of every single line of text in that text file, save and close.
推荐答案
这样的事情应该可行:
function append-text {
process{
foreach-object {$_ + "*"}
}
}
这篇关于使用 PowerShell 将文本添加到文本文件中的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文