summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJonathan Wang <jonathansw@outlook.com>2016-06-26 09:04:11 -0400
committerven <vendethiel@hotmail.fr>2016-06-26 15:04:11 +0200
commit8cd7c230aaa708dffb544887baa85de8f3377251 (patch)
treeaa2ff31e0f0aaa87537f8862fe6b1f6bd107b2d6
parentd9caa2436e6ebe63e9b2287725c4e104ddcb88cb (diff)
[bash/en] basic parameter expansion, and brace expansion (#1533)
* Added brace expansion as well as basic parameter expansion * frogot my name * Update bash.html.markdown Added to parameter expansion
-rw-r--r--bash.html.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index c2c3e3f1..a62bd167 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -11,6 +11,7 @@ contributors:
- ["Rahil Momin", "https://github.com/iamrahil"]
- ["Gregrory Kielian", "https://github.com/gskielian"]
- ["Etan Reisner", "https://github.com/deryni"]
+ - ["Jonathan Wang", "https://github.com/Jonathansw" ]
filename: LearnBash.sh
---
@@ -54,6 +55,13 @@ echo '$Variable'
# its name without $. If you want to use the variable's value, you should use $.
# Note that ' (single quote) won't expand the variables!
+# Parameter expansion ${ }:
+echo ${Variable}
+# This is a simple usage of parameter expansion
+# Parameter Expansion gets a value from a variable. It "expands" or prints the value
+# During the expansion time the value or parameter are able to be modified
+# Below are other modifications that add onto this expansion
+
# String substitution in variables
echo ${Variable/Some/A}
# This will substitute the first occurrence of "Some" with "A"
@@ -68,6 +76,12 @@ echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"}
# This works for null (Foo=) and empty string (Foo=""); zero (Foo=0) returns 0.
# Note that it only returns default value and doesn't change variable value.
+# Brace Expansion { }
+# Used to generate arbitrary strings
+echo {1..10}
+echo {a..z}
+# This will output the range from the start value to the end value
+
# Builtin variables:
# There are some useful builtin variables, like
echo "Last program's return value: $?"