summaryrefslogtreecommitdiffhomepage
path: root/bash.html.markdown
diff options
context:
space:
mode:
authoralexandre medeiros <alexandre.medeiros@students.ic.unicamp.br>2013-09-22 01:29:05 -0300
committeralexandre medeiros <alexandre.medeiros@students.ic.unicamp.br>2013-09-22 01:33:12 -0300
commit9d0f731ad5c6e3e9ccda43651eb4f445fc8234f0 (patch)
tree1b011d8da49426e3613b763400122f274123bf42 /bash.html.markdown
parentc14586e8c3c285b34c20358fa97e44aeed356dde (diff)
Improve bash variable info
Diffstat (limited to 'bash.html.markdown')
-rw-r--r--bash.html.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 41d0669e..81565b6d 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -36,8 +36,22 @@ VARIABLE = "Some string"
# Using the variable:
echo $VARIABLE
echo "$VARIABLE"
+echo '$VARIABLE'
# When you use the variable itself — assign it, export it, or else — you write
# its name without $. If you want to use variable's value, you should use $.
+# Note that ' (single quote) won't expand the variables!
+
+# String substitution in variables
+echo ${VARIABLE/Some/A}
+# This will substitute the first occurance of "Some" with "A"
+
+# Bultin variables:
+# There are some useful builtin variables, like
+echo "Last program return value: $?"
+echo "Script's PID: $$"
+echo "Number of arguments: $#"
+echo "Scripts arguments: $@"
+echo "Scripts arguments separeted in different variables: $1 $2..."
# Reading a value from input:
echo "What's your name?"