$
学ぶ Linux ハンドブック
ja
XP:0
クエスト 36Documenter
+250 XP

Multi-Line Input with Here-Docs (<<EOF)

このクエストの対話型ターミナルを起動する→インストール不要 • ブラウザ上で完全動作

概念と概要

In automated scripts and cloud deployment routines (like Dockerfiles or cloud-init), opening an interactive text editor like nano is impossible. Instead, Bash uses Here-Documents (<) to inject multi-line blocks of text directly into commands.

The syntax cat < config.env tells the shell to capture all following lines into config.env until a line containing only the delimiter word EOF is reached.

Use a here-doc to create an environment configuration file! Run cat < config.env, enter the lines:
NODE_ENV=production
PORT=3000
and terminate the here-doc with EOF on its own line.

コマンド構文リファレンス

Command / SyntaxDescription
cat <<EOF > config.envBegin multi-line here-doc writing to config.env
EOFDelimiter word marking the end of here-doc input

検証目標

  • ○
    Create config.env using a here-doc (<<EOF)
  • ○
    Verify config.env contains NODE_ENV=production and PORT=3000

クエスト完了への準備はできましたか? 36?