bash - Unset variables declared in file -
say have object.properties
, looks like
test=1 hello=2 foo=3
let's these variables in environment. how can unset of them? i.e.
unset test hello foo
using simple bashfaq #1 loop:
while ifs='=' read -r key value; unset "$key" done <object.properties
or, if have bash 4.0 or newer, can couple readarray
(the shell builtin known mapfile
) parameter expansion:
readarray -t lines <object.properties unset "${lines[@]%%=*}"
Comments
Post a Comment