0
0

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 3 years have passed since last update.

Windowsターミナルでコマンドラインの変数を定義する方法

Last updated at Posted at 2022-04-19

Windowsでコマンドラインの変数を定義する。

こんにちは、k_uki512です。
現在は、「AWSで始めるクラウド開発入門」という書籍でAWSの勉強をしています。
この中で、コマンドライン変数を定義する箇所が出てきたのですが、本通りではエラーが出てしまったのでその解決法をまとめていきます。

Linuxの変数定義の仕方

Linux(Ubuntu)では以下のような書き方で変数を定義します。

content="hogehoge" //変数名=文字列

また、変数の出力は以下のように行います。

echo $content

書籍ではLinuxのコマンドが記載されていたため、このまま入力してもwindowsのターミナルではエラーが出てきてしまいます。

Windowsで変数定義をする。

Windowsでの変数定義の仕方を調べているうちにsetコマンドというコマンドがあることを知りました。今回はそれを使用すればよさそうです。

そのため、windowsでの変数定義は以下のようにコマンドを入力します。

set content=hogehoge

また、入力は以下のようなコマンドになります。

echo %content%

同じ書籍を使っていて、変数定義に詰まっている方、windowsでの変数定義に困っている方に届けばと思います。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?