1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

catコマンドでファイルに書き込み(上書き&追記)

Last updated at Posted at 2022-09-23

ファイルの中身を確認

# cat test.txt 
abc

ファイルの上書き

入力完了後、[ctrl]+[d]で上書き

# cat > test.txt 
ABCDE

以下の入力のみで上書き

# cat <<EOF > test.txt
> ABC
> EOF

ファイルに追記

入力完了後、[ctrl]+[d]で追記

# cat >> test.txt 
FGHIJ

以下の入力のみで追記

# cat <<EOF >> test.txt 
> KLMNO
> EOF

普通にコマンドラインで書き込むなら、viで書き込めば良い。
自動化させるとか、マニュアルに落とし込んで誰でも使えるようにするときは、こっちの方がいいかも。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?