LoginSignup
0
0

More than 5 years have passed since last update.

環境変数を検索して一括で unset するワンライナー

Posted at

環境変数名を検索して一括で unset:

unset `env | grep -iE foo.*= | sed -e s/=.*//g`

環境変数の値を検索して一括で unset:

unset `env | grep -iE =.*foo | sed -e s/=.*//g`

説明

上記のワンライナーで、名前や値に foo (大文字小文字は不問)が入っている環境変数を unset できます。

応用

したいこと 方法
大文字小文字が一致するように検索するには grep の i オプションをなくします
名前と値両方を検索するには grep の部分を grep -i foo とします
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