2023-02-03 14:51:52 +00:00
|
|
|
---
|
|
|
|
categories:
|
|
|
|
- Programming Languages
|
|
|
|
tags:
|
|
|
|
- shell
|
|
|
|
---
|
|
|
|
|
2023-02-10 18:22:04 +00:00
|
|
|
# Quote marks in Bash
|
2023-02-03 14:51:52 +00:00
|
|
|
|
|
|
|
## Single-quotes (aka _strong_ quotes)
|
|
|
|
|
|
|
|
Bash will interpret everything in the string as a literal:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo 'The directory is $(pwd)'
|
|
|
|
# The directory is $(pwd)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Double-quotes
|
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
Bash will interpret strings as strings but will interpret expansions and
|
|
|
|
substitutions as executable processes:
|
2023-02-03 14:51:52 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$pointlessVar='directory'
|
|
|
|
|
|
|
|
echo "The ${pointlessVar}"
|
|
|
|
|
|
|
|
# The directory is /home/thomas
|
|
|
|
```
|
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
It is therefore generally best to use double quotes whenever we wish to return
|
|
|
|
mixed values.
|