小编Jos*_*hua的帖子

使用PowerShell将文本添加到文本文件中的每一行

我想在.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)

这样的事情.本质上,加载给定的文本文件,在该文本文件中的每一行文本的末尾添加"*",保存并关闭.

powershell powershell-2.0

15
推荐指数
2
解决办法
4万
查看次数

Windows PowerShell 2.0绝对是初学者 - 本书最后一个项目的错误

通过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)

powershell powershell-2.0

1
推荐指数
1
解决办法
2697
查看次数

标签 统计

powershell ×2

powershell-2.0 ×2