|
From: | Chris F.A. Johnson |
Subject: | Re: [Help-bash] The best way to derefrence a variable whose name is stored in another variable. |
Date: | Fri, 24 Apr 2015 16:56:00 -0400 (EDT) |
User-agent: | Alpine 2.10 (DEB 1266 2009-07-14) |
On Fri, 24 Apr 2015, Peng Yu wrote:
Hi I use the following code to test if the variable name stored in "x" actually have any value set. But I am not sure if it is the best way to do. Does anybody know what is the best way to do so in bash? #!/usr/bin/env bash var=10 x=var
[[ -n "${!x}" ]] && echo yes || echo no -- Chris F.A. Johnson, <http://cfajohnson.com>
[Prev in Thread] | Current Thread | [Next in Thread] |