help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] append to $@ one by one


From: Peng Yu
Subject: [Help-bash] append to $@ one by one
Date: Sat, 19 Oct 2019 20:11:55 -0500

Hi,

I use the following code to read from stdin and set $@ at once. But it
involves an additional variable "a". Is there a way to avoid such a
variable by appending to $@ one by one (but it should not be too slow,
so `set -- "$@" "$x"` will not work.)

while IFS= read -r x; do
  a+=("$x")
done
set -- "${a[@]}"

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]