$ cat > target.txt << EOF >hello >world >foo >bar >EOF $ cat target.txt hello world foo bar
シェルスクリプトファイル内では、以下のように記述できる。
#!/bin/bash # target.txtに複数行テキストをリダイレクト出力 cat > target.txt << EOF hello world foo bar EOF # target.txtの内容を表示 cat target.txt
$ ./test.sh hello world foo bar
"EOF"
というマーカー文字列は、他の文字列、例えば “END” や “END_OF_LINES” など何でもよい。