我想在.txt文档的每行文本的末尾添加字符.
#Define Variables
$a = c:\foobar.txt
$b = get-content $a
#Define Functions
function append-text
{
foreach-Object
{
add "*"
}
}
#Process Code
$b | append-text
Run Code Online (Sandbox Code Playgroud)
这样的事情.本质上,加载给定的文本文件,在该文本文件中的每一行文本的末尾添加"*",保存并关闭.
通过Jerry Lee Ford Jr.的Powershell 2.0 for Absolute Beginner一书.本书的代码中有很多印刷错误,我已经能够通过并纠正(很棒的练习),但有一个我根本无法弄清楚.从配套网站下载了他的股票代码,他的代码抛出完全相同的错误.代码如下:
# *************************************************************************
#
# Script Name: GameConsole.ps1 (The PowerShell Game Console)
# Version: 1.0
# Author: Jerry Lee Ford, Jr.
# Date: January 1, 2007
#
# Description: This PowerShell script provides a listing of PowerShell
# game scripts and allows the player to play any game by
# entering its menu number.
#
# *************************************************************************
# Initialization Section
$menuList = @() #Stores an array containing information about script games
$playAgain = …Run Code Online (Sandbox Code Playgroud)