From dbb858281a8c5948606ad3a07225915954a03953 Mon Sep 17 00:00:00 2001 From: kfrncs Date: Fri, 20 Jul 2018 14:38:59 -0400 Subject: missing $ on line 77 - $Length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maybe just a zsh quirk? ➜ ~ echo ${Variable:0:Length} zsh: unrecognized modifier --- bash.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index 3f3e49eb..d1e6bf25 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -74,7 +74,7 @@ echo ${Variable/Some/A} # => A string # Substring from a variable Length=7 -echo ${Variable:0:Length} # => Some st +echo ${Variable:0:$Length} # => Some st # This will return only the first 7 characters of the value # Default value for variable -- cgit v1.2.3 From 6f0aec01c577e44b1ea3260f786ef3527eebf204 Mon Sep 17 00:00:00 2001 From: Aidas Bendoraitis Date: Wed, 25 Jul 2018 23:58:31 +0200 Subject: shebang updated --- bash.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index 3f3e49eb..f2a72fdb 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -25,7 +25,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/bash +#!/usr/bin/env 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. -- cgit v1.2.3 From 088111396a0dff9a5dff7837e1ae74aa9314b620 Mon Sep 17 00:00:00 2001 From: Tucker Boniface Date: Tue, 2 Oct 2018 19:19:18 -0700 Subject: [bash/en] clarify quoted delimiter for heredocs (fixes #3061) --- bash.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index cb805da7..1f59636e 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -256,6 +256,7 @@ print("#stderr", file=sys.stderr) for line in sys.stdin: print(line, file=sys.stdout) EOF +# Variables will be expanded if the first "EOF" is not quoted # Run the hello.py Python script with various stdin, stdout, and # stderr redirections: -- cgit v1.2.3 From 843626f3d30a06cc1c8b342c155a5dc8af24fbd1 Mon Sep 17 00:00:00 2001 From: Tucker Boniface Date: Tue, 2 Oct 2018 19:23:45 -0700 Subject: [bash/en] add `cd` and `cd -` uses --- bash.html.markdown | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index cb805da7..e609260f 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -228,10 +228,13 @@ mv s0urc3.txt dst.txt # sorry, l33t hackers... # Since bash works in the context of a current directory, you might want to # run your command in some other directory. We have cd for changing location: cd ~ # change to home directory +cd # also goes to home directory cd .. # go up one directory # (^^say, from /home/username/Downloads to /home/username) cd /home/username/Documents # change to specified directory cd ~/Documents/.. # still in home directory..isn't it?? +cd - # change to last directory +# => /home/username/Documents # Use subshells to work across directories (echo "First, I'm here: $PWD") && (cd someDir; echo "Then, I'm here: $PWD") -- cgit v1.2.3 From 9152fe00e54b51ddebaeed9929a3027547cb16a5 Mon Sep 17 00:00:00 2001 From: Tucker Boniface Date: Tue, 2 Oct 2018 19:22:56 -0700 Subject: [bash/en] clarify range of substring --- bash.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index cb805da7..be879538 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -75,7 +75,7 @@ echo ${Variable/Some/A} # => A string # Substring from a variable Length=7 echo ${Variable:0:$Length} # => Some st -# This will return only the first 7 characters of the value +# This will return 7 characters of the string, starting from the first char # Default value for variable echo ${Foo:-"DefaultValueIfFooIsMissingOrEmpty"} -- cgit v1.2.3