Unset all ENV variables matching _PROXY
That's because unset
is a shell builtin and not an external command. This means that xargs
can't use it since that only runs commands that are in your $PATH
. You'd get the same problem if you tried with cd
:
$ ls -l
total 4
drwxr-xr-x 2 terdon terdon 4096 Jun 16 02:02 foo
$ echo foo | xargs cd
xargs: cd: No such file or directory
One way around this is to use a shell loop which, since it is part of the shell, will be able to run shell builtins. I also simplified your command a bit, there's no need for column
, you can set the field separator for awk
and there's no need for a second grep
, just tell awk
to print lines that don't match no_proxy
:
while read var; do unset $var; done < <(env | grep -i proxy |
awk -F= '!/no_proxy/{print $1}')
unset `env | grep _PROXY | egrep -o '^[^=]+'`