LoginSignup
12
12

More than 5 years have passed since last update.

あるファイルを別のファイルに連結させる

Posted at

タイトルの通りです。あるファイル A.txt の内容を別のファイル B.txt の末尾に連結させます。

concat.ps1
Get-Content A.txt | Add-Content B.txt

たったこれだけで、元々の B.txt に A.txt の内容が追記されます。

さらに何も考えずに同じ A.txt を複数回 B.txt に追記したい場合も簡単です。

concatMany.ps1
# 3回 A.txt の内容を B.txt に追記する
1..3 | ForEach { Get-Content A.txt | Add-Content B.txt }

本当に、たったこれだけです。

何に使えるの?とお思いの方もいらっしゃると思いますが、僕もそう思います。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12