From 2849a054633b62a3c863edefd9b5c87a6834db81 Mon Sep 17 00:00:00 2001 From: Crestwave Date: Sat, 19 Jan 2019 18:19:19 +0800 Subject: [PATCH] Add "Name a variable based on another variable" entry --- README.md | 10 ++++++++++ manuscript/chapter6.txt | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 56f174b..2ce259a 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ See something incorrectly described, buggy or outright wrong? Open an issue or s * [Get the base-name of a file path](#get-the-base-name-of-a-file-path) * [VARIABLES](#variables) * [Assign and access a variable using a variable](#assign-and-access-a-variable-using-a-variable) + * [Name a variable based on another variable](#name-a-variable-based-on-another-variable) * [ESCAPE SEQUENCES](#escape-sequences) * [Text Colors](#text-colors) * [Text Attributes](#text-attributes) @@ -1046,6 +1047,15 @@ $ printf '%s\n' "$ref" value ``` +## Name a variable based on another variable + +```shell +$ var="world" +$ declare hello_$var=value +$ printf '%s\n' "$hello_world" +value +``` + diff --git a/manuscript/chapter6.txt b/manuscript/chapter6.txt index 5a280d1..cd2a01e 100644 --- a/manuscript/chapter6.txt +++ b/manuscript/chapter6.txt @@ -27,5 +27,14 @@ $ printf '%s\n' "$ref" value ``` +## Name a variable based on another variable + +```shell +$ var="world" +$ declare hello_$var=value +$ printf '%s\n' "$hello_world" +value +``` +