From dd7d40a2915be60dfad2d5ad0e00eb5714904e62 Mon Sep 17 00:00:00 2001 From: "Matthew L. Curry" Date: Sun, 20 Oct 2019 20:17:36 +0000 Subject: [PATCH 1/2] Note to prefer $() over ``, and update single example to conform --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6d14d1..c4198d6 100644 --- a/README.md +++ b/README.md @@ -299,6 +299,8 @@ now=$(date +%T) echo $now # 19:08:26 ``` +Many prefer `$()` over ``` `` ``` because the latter cannot be nested, and the back-tick character is easy to mistake for an apostrophe in print. + ## Arithmetic expansion In bash we are free to do any arithmetical operations. But the expression must enclosed by `$(( ))` The format for arithmetic expansions is: @@ -641,9 +643,9 @@ Sometimes `if..else` statements are not enough to do what we want to do. In this Look at the example below: ```bash -if [[ `uname` == "Adam" ]]; then +if [[ $(uname) == "Adam" ]]; then echo "Do not eat an apple!" -elif [[ `uname` == "Eva" ]]; then +elif [[ $(uname) == "Eva" ]]; then echo "Do not take an apple!" else echo "Apples are delicious!" From caf35caadf5d92a08cd3b0e93edf883e85baa5d6 Mon Sep 17 00:00:00 2001 From: "Matthew L. Curry" Date: Sun, 27 Oct 2019 04:14:22 -0600 Subject: [PATCH 2/2] Change order of examples for nested commands to prefer $() --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c4198d6..6160ae6 100644 --- a/README.md +++ b/README.md @@ -289,12 +289,12 @@ echo {00..8..2} # 00 02 04 06 08 ## Command substitution -Command substitution allow us to evaluate a command and substitute its value into another command or variable assignment. Command substitution is performed when a command is enclosed by ``` `` ``` or `$()`. For example, we can use it as follows: +Command substitution allow us to evaluate a command and substitute its value into another command or variable assignment. Command substitution is performed when a command is enclosed by `$()` or ``` `` ```. For example, we can use it as follows: ```bash -now=`date +%T` -# or now=$(date +%T) +# or +now=`date +%T` echo $now # 19:08:26 ```