LoginSignup
13
8

More than 5 years have passed since last update.

powershellでファイルをクリアする

Last updated at Posted at 2013-05-08

Bashで言うところのcat /dev/null > test.txtを実現するための方法。
他にもいろんな方法があると思うけどとりあえずオーソドックスっぽい方法をメモ。

echo $null > test.txt

test.txtがなければ空のファイルを作成する。
$nullは予約変数(自動変数?)で、空のオブジェクトを表す。

↓2013/5/13追記
ファイルのクリアだけならClear-Content test.txtでできることがわかった。
ファイルが無いときはエラーにしたい時などはこっちのほうがよいかも。

13
8
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
13
8