Have any way to unset different variables using a one command?
unset HTTP_PROXY
unset HTTPS_PROXY
unset FTP_PROXY
unset ALL_PROXY
unset NO_PROXY
Have any way to unset different variables using a one command?
unset HTTP_PROXY
unset HTTPS_PROXY
unset FTP_PROXY
unset ALL_PROXY
unset NO_PROXY
unset
takes multiple variables:
unset HTTP_PROXY HTTPS_PROXY FTP_PROXY ALL_PROXY NO_PROXY
A little bit late, but anyway. Depending on your variable pattern you can shorten your unset:
env
or compgen -v
.grep
or sed
.unset
.For example in your case it can be:
unset $(compgen -v | grep "_PROXY$")
It's not exactly one command, but it imitates unset *_PROXY
, as you requested in your comment.
Using babashka:
bb -o '(->> (System/getenv)
keys
(filter #(str/ends-with? % "_PROXY"))
(map #(str "unset " %)))' |
source /dev/stdin