diff options
author | jakub-g <jakub.g.opensource@gmail.com> | 2013-12-09 13:17:20 +0100 |
---|---|---|
committer | jakub-g <jakub.g.opensource@gmail.com> | 2013-12-09 21:13:06 +0100 |
commit | 248284c91b641f2bd635dfe5a640f1fd3b8cd6a3 (patch) | |
tree | 5be205d4a53f9ab8affe2a766195dcda62185b7a /bash.html.markdown | |
parent | d71ac35d72529d3dee08d9591cd1c65cbdcccb6d (diff) |
[bash] Replace `seq` with `{1..3}`, explain backticks
`seq` is not standard, it's not available in MINGW and others.
Using backticks is not the recommended way - e.g. they can't be nested.
Diffstat (limited to 'bash.html.markdown')
-rw-r--r-- | bash.html.markdown | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index afc46eb0..1f1c32c0 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -99,6 +99,10 @@ python2 hello.py 2> "error.err" # current directory. echo "There are $(ls | wc -l) items here." +# The same can be done using backticks `` but they can't be nested - the preferred way +# is to use $( ). +echo "There are `ls | wc -l` items here." + # Bash uses a case statement that works similarly to switch in Java and C++: case "$VARIABLE" in #List patterns for the conditions you want to meet @@ -109,8 +113,7 @@ esac # For loops iterate for as many arguments given: # The contents of var $VARIABLE is printed three times. -# Note that ` ` is equivalent to $( ) and that seq returns a sequence of size 3. -for VARIABLE in `seq 3` +for VARIABLE in {1..3} do echo "$VARIABLE" done |