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 1 year has passed since last update.

【Linux】シェルの変数について

0
Last updated at Posted at 2024-01-27

変数の設定方法

例)TODAY変数を出力すると,dateコマンドの結果が表示されるようにする。
変数は以下の2通りで設定できる。

ubuntu
user:~ $TODAY=`date`
user:~ TODAY=$(date)

変数の出力方法

echoと$を使う

ubuntu
user:~ echo $TODAY
2024 1 27 土曜日 20:11:52 JST

規定の変数

$?

直前のコマンドの終了ステータスを設定

ubuntu
user:~ echo $?
127

$?

現在のシェルのプロセス番号

ubuntu
user:~ echo  $$
169

$*

全ての引数が格納される

${10}

10番目の引数が格納される

$0

実行したシェルスクリプト名が設定される

ubuntu
user:~ echo $0
-bash
0
0
2

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?