- PowerShell 教程
- PowerShell - 主頁
- PowerShell - 概述
- PowerShell - 環境設定
- PowerShell - Cmdlet
- PowerShell - 檔案和資料夾
- PowerShell - 日期和時間
- PowerShell - 檔案 I/O
- PowerShell - 高階 Cmdlet
- PowerShell - 指令碼編寫
- PowerShell - 特殊變數
- PowerShell - 運算子
- PowerShell - 迴圈
- PowerShell - 條件
- PowerShell - 陣列
- PowerShell - 雜湊表
- PowerShell - 正則表示式
- PowerShell - 反引號
- PowerShell - 括號
- PowerShell - 別名
- PowerShell 有用資源
- PowerShell - 快速指南
- PowerShell - 有用資源
- PowerShell - 討論
PowerShell - 向檔案追加內容
命令
Add-Content cmdlet 可用於追加任意檔案的內容。
在此示例中,我們要新增 test.txt 的內容。
步驟 1
在此示例中,我們要在名為 test.txt 的新 txt 檔案中設定內容。
在 PowerShell ISE 控制檯中輸入以下命令
Set-Content D:\temp\test\test.txt 'Hello'
步驟 2
在此示例中,我們要向 test.html 追加內容。
在 PowerShell ISE 控制檯中輸入以下命令
Add-Content D:\temp\test\test.txt 'World!'
步驟 3
在此示例中,我們要讀取 test.html 的內容。
Get-Content D:\temp\test\test.txt
輸出
您可以在 PowerShell 控制檯中看到以下輸出。
Hello World!
powershell_files_io.htm
廣告