[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
removing null elements from an array
From: |
Poor Yorick |
Subject: |
removing null elements from an array |
Date: |
Thu, 17 Jul 2008 23:12:47 +0000 |
To get rid of null elements in an array, I currently do something like this:
bash-3.2$ var1=("with spaces" "more spaces" '' "the end")
bash-3.2$ for v in "address@hidden"; do if test "$v"; then var2+=("$v");
fi; done
bash-3.2$ echo address@hidden
3
bash-3.2$ printf '%s\n' "address@hidden"
with spaces
more spaces
the end
Is there any other more concise way? It would be nice to avoid the second
variable by doing something like this:
bash-3.2$ var1=("address@hidden:-}")
Is it a feasible syntax for future releases?
--
Yorick
- removing null elements from an array,
Poor Yorick <=