Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tutorials/learnshell.org/en/Variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Referencing the variables
A backslash "\\" is used to escape special character meaning

PRICE_PER_APPLE=5
echo "The price of an Apple today is: \$HK $PRICE_PER_APPLE"
echo "The price of an Apple today is: \$ $PRICE_PER_APPLE"

Encapsulating the variable name with ${} is used to avoid ambiguity

Expand All @@ -27,7 +27,8 @@ Encapsulating the variable name with "" will preserve any white space values
Variables can be assigned with the value of a command output. This is referred to as substitution. Substitution can be done by encapsulating the command with `` (known as back-ticks) or with $()

FILELIST=`ls`
FileWithTimeStamp=/tmp/my-dir/file_$(/bin/date +%Y-%m-%d).txt
echo "The current directory contains the following files and folders:"$FILELIST
echo "The current directory contains the following files and folders:"$(`ls`)

Note that when the script runs, it will run the command inside the $() parenthesis and capture its output.

Expand Down