3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Bashやシェルスクリプトで使用される"$()"と"${}"の違い

Posted at

"$()"の場合

コマンド置き換え と言われ、内部でコマンドを実行し、その結果を展開する。

echo "Today is $(date)"
# "Today is Mon Aug 12 23:45:37 JST 2024" のように表示される

"${}"の場合

変数を参照するために使用される構文。中括弧は省略可能な場合もある。明示的に変数と分かるようにするのも可。

name="World"
echo "Hello, ${name}!"
# "Hello, World!"
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?