summaryrefslogtreecommitdiffhomepage
path: root/bash.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'bash.html.markdown')
-rw-r--r--bash.html.markdown8
1 files changed, 6 insertions, 2 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index a6bd2b7c..d5d08e9d 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -15,7 +15,7 @@ Nearly all examples below can be a part of a shell script or executed directly i
[Read more here.](http://www.gnu.org/software/bash/manual/bashref.html)
```bash
-#!/bin/sh
+#!/bin/bash
# First line of the script is shebang which tells the system how to execute
# the script: http://en.wikipedia.org/wiki/Shebang_(Unix)
# As you already figured, comments start with #. Shebang is also a comment.
@@ -46,11 +46,15 @@ echo '$VARIABLE'
echo ${VARIABLE/Some/A}
# This will substitute the first occurance of "Some" with "A"
+# Substring from a variable
+echo ${VARIABLE:0:7}
+# This will return only the first 7 characters of the value
+
# Default value for variable
echo ${FOO:-"DefaultValueIfFOOIsMissingOrEmpty"}
# This works for null (FOO=), empty string (FOO=""), zero (FOO=0) returns 0
-# Bultin variables:
+# Builtin variables:
# There are some useful builtin variables, like
echo "Last program return value: $?"
echo "Script's PID: $$"