2
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?

More than 1 year has passed since last update.

env コマンドの出力結果をソートして環境変数を確認する(環境変数のソート済み出力)

Last updated at Posted at 2020-09-19

Linux/macOS で定義済みの環境変数を確認しようと env コマンドを実行したら順番がバラバラなのでソートしたい。

「env ソート」でググっても、ピンポイントの記事がなかったので、自分のググラビリティ(備忘録)として。

TL; DR (今北産業)

env コマンドにはソート・オプションはありません。
パイプ渡しして、sort コマンドでソートする必要があります。

env をソートする例
env | sort

TS; DR

ソート・オプションがありそうでなかった。

Debian
$ # バージョン
$ env --version | head -n1
env (GNU coreutils) 8.30

$ # ヘルプを確認 → 項目がない
$ echo "$(env --help)" | grep sort
macOS
$ # バージョン
$ echo "$(man env)" | tail -n1
BSD                             April 17, 2008                             BSD

$ # マニュアル(man env)から確認 → 項目がない
$ echo "$(man env)" | grep sort

2
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
2
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?