help-bash
[Top][All Lists]
Advanced

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

Re: looping over variables & exporting them at the same time ?


From: Greg Wooledge
Subject: Re: looping over variables & exporting them at the same time ?
Date: Sun, 28 Jan 2024 23:07:35 -0500

On Sun, Jan 28, 2024 at 10:11:43PM -0500, Zachary Santer wrote:
>     # Surround the contents of var with spaces
>     var=" ${var} "
>     # Replace all instances of " xtest " in the variable with " "
>     var="${var// xtest / }"
>     # Remove the leading space we added
>     var="${var# }"
>     # Remove the trailing space we added
>     var="${var% }"

While this does work, I still prefer treating a list as a real list,
and expanding it out into an array for whatever operations are desired.
If the problem evolves, and the desired operations become more complex --
or if the problem statement we've been given is not complete -- then
having the list items in separate array elements will be an advantage.



reply via email to

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