LoginSignup
22
18

More than 5 years have passed since last update.

空のファイルを作る2つの方法

Posted at

何かと作成する必要のある空のファイル。touchコマンドとechoコマンドを使って作成することができます。

touch コマンドを使う

$ touch null_file

echo コマンドを使う

$ echo -n > null_file

echoの出力はデフォルトで最後に改行が加えられます。

これを回避するために、オプションで-nを指定し改行コードを含まないようにしています。

オプションを指定しなければ、改行コードのみの1バイトのファイルができてしまうので気をつけましょう。

22
18
2

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
22
18