Bash 取消设置文件中声明的变量

Bash 取消设置文件中声明的变量,bash,Bash,假设我有object.properties,它看起来像 test=1 hello=2 foo=3 假设所有这些变量都在环境中。我怎样才能解除所有这些?i、 e unset test hello foo 使用简单循环: 使用简单循环: while IFS='=' read -r key value; do unset "$key" done <object.properties readarray -t lines <object.properties unset "${li

假设我有
object.properties
,它看起来像

test=1
hello=2
foo=3
假设所有这些变量都在环境中。我怎样才能解除所有这些?i、 e

unset test hello foo
使用简单循环:

使用简单循环:

while IFS='=' read -r key value; do
  unset "$key"
done <object.properties
readarray -t lines <object.properties
unset "${lines[@]%%=*}"