シェルスクリプト（Bash）の記号の意味

## 概要

検索しにくいBashの記号の意味をまとめてみた。

## 目次

- 記号
  - [`space`](#スペース-space-sp-記号の意味) [`!`](#ビックリマーク-bang--記号の意味) [`"`](#ダブルクォート-double-quotation-mark--記号の意味) [`'`](#シングルクォート-single-quotation-mark--記号の意味) [`#`](#ナンバーサイン-number-sign-井桁-シャープ--記号の意味) [`$`](#ドル記号-dollar-sign--記号の意味) [`%`](#パーセント記号-percent-sign--記号の意味) [`&`](#アンパサンド-ampersand--記号の意味) [`()`](#括弧-parenthesis-丸括弧--記号の意味) [`*`](#アスタリスク-asterisk--記号の意味) [`@`](#アットマーク-at-sign--記号の意味) [`+`](#プラス記号-plus-sign--記号の意味) [`,`](#コンマ-comma--記号の意味) [`-`](#ハイフン-マイナス-hyphen-minus---記号の意味) [`.`](#ドット-dot-ピリオド--記号の意味) [`/`](#スラッシュ-slash--記号の意味) [`:`](#コロン-colon--記号の意味) [`;`](#セミコロン-semicolon--記号の意味) [`<`](#小なり-less-than-sign--記号の意味) [`=`](#等号-equals-sign-イコール--記号の意味) [`>`](#大なり-greater-than-sign--記号の意味) [`?`](#はてな-question-mark-疑問符--記号の意味) [`[]`](#角括弧-bracket-ブラケット--記号の意味) [`\`](#バックスラッシュ-backslash--記号の意味) [`^`](#サーカムフレックス-circumflex-hat-ハット--記号の意味) [`_`](#アンダースコア-underscore-_-記号の意味) [`` ` ``](#バッククォート-backquote--記号の意味) [`{}`](#波括弧-curly-bracket--記号の意味) [`|`](#縦棒-vertical-lineバーティカルライン--記号の意味) [`~`](#チルダ-tilde--記号の意味)
- 後付
  - [Bashリファレンスマニュアル](#bashリファレンスマニュアル)

## スペース (Space) SP 記号の意味

### [Word Splitting](https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html#Word-Splitting)

書式:

```bash
word1 word2
```

## ビックリマーク (Bang) ! 記号の意味

### [Pipelines](https://www.gnu.org/software/bash/manual/html_node/Pipelines.html#Pipelines)

書式:

```bash
! command1 && command2
```

### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

書式:

```bash
$!
```

### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
"${!prefix@}"
```

```bash
${!name[@]}
```


### [Shell Scripts](https://www.gnu.org/software/bash/manual/html_node/Shell-Scripts.html#Shell-Scripts)

例:

```bash
#! /bin/bash
```


### [Bash Conditional Expressions](https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html#Bash-Conditional-Expressions)

例:

```bash
[[ string1 != string2 ]]
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( !(1 == 2) ))
```

```bash
(( 1 != 2 ))
```

### [History Interaction](https://www.gnu.org/software/bash/manual/html_node/History-Interaction.html#History-Interaction)

例:

```bash
!!
```

## ダブルクォート (Double quotation mark) " 記号の意味

### [Double Quotes](https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#Double-Quotes)

例:

```bash
""
```


## シングルクォート (Single quotation mark) ' 記号の意味

### [Single Quotes](https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html#Single-Quotes)

例:

```bash
''
```


### [ANSI-C Quoting](https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html#ANSI_002dC-Quoting)

例:

```bash
$'\n'
```


## ナンバーサイン (Number sign, 井桁, シャープ) # 記号の意味

### [Comments](https://www.gnu.org/software/bash/manual/html_node/Comments.html#Comments)

書式:

```bash
# Comments
```


### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$#
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${#parameter}
```

```bash
${parameter#word}
```

```bash
${parameter##word}
```


### [Shell Scripts](https://www.gnu.org/software/bash/manual/html_node/Shell-Scripts.html#Shell-Scripts)

例:

```bash
#! /bin/bash
```


## ドル記号 (Dollar sign) $ 記号の意味

### [ANSI-C Quoting](https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html#ANSI_002dC-Quoting)

書式:

```bash
$'string'
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
[[ abc =~ c$ ]]
```


### [Shell Parameters](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html#Shell-Parameters)

例:

```bash
${var}
```


### [Positional Parameters](https://www.gnu.org/software/bash/manual/html_node/Positional-Parameters.html#Positional-Parameters)

例:

```bash
$1
```


### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$$
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter:-word}
```


### [Command Substitution](https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html#Command-Substitution)

書式:

```bash
$(command)
```


### [Arithmetic Expansion](https://www.gnu.org/software/bash/manual/html_node/Arithmetic-Expansion.html#Arithmetic-Expansion)

例:

```bash
$(( 1 + 1 ))
```


## パーセント記号 (Percent sign) % 記号の意味

### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter%word}
```

```bash
${parameter%%word}
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
$(( 3 % 2 ))
```

```bash
(( i %= 5 ))
```


### [Job Control Basics](https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html#Job-Control-Basics)

例:

```bash
fg %
```


## アンパサンド (Ampersand) & 記号の意味

### [Pipelines](https://www.gnu.org/software/bash/manual/html_node/Pipelines.html#Pipelines)

書式:

```bash
|&
```


### [Lists](https://www.gnu.org/software/bash/manual/html_node/Lists.html#Lists)

書式:

```bash
command &
```

```bash
command1 && command2
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

`;&` `;:&`

```bash
[[ expression1 && expression2 ]]
```


### [Redirections](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirections)

例:
`>&-` `<&-` `&>` `>&` `&>>` `2>&1`

### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i % 30 == 0 && i % 42 == 0 ))
```


## 括弧 (Parenthesis, 丸括弧) () 記号の意味

### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
case "$-" in *i*) echo interactive ;; *) echo not interactive ;; esac
```


### [Command Grouping](https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html#Command-Grouping)

書式:

```bash
( )
```


### [Shell Functions](https://www.gnu.org/software/bash/manual/html_node/Shell-Functions.html#Shell-Functions)

書式:

```bash
name () compound-command
```


### [Looping Constructs](https://www.gnu.org/software/bash/manual/html_node/Looping-Constructs.html#Looping-Constructs)

例:

```bash
for (( i=1; i <= 10; i++ )); do echo $i; done
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
(( n == 42 ))
```


### [Arithmetic Expansion](https://www.gnu.org/software/bash/manual/html_node/Arithmetic-Expansion.html#Arithmetic-Expansion)

例:

```bash
$(( i++ ))
```


### [Arrays](https://www.gnu.org/software/bash/manual/html_node/Arrays.html#Arrays)

例:

```bash
name=(value1 value2 … )
```


## アスタリスク (Asterisk) * 記号の意味

### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
case "$-" in *i*) echo interactive ;; *) echo not interactive ;; esac
```


### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$*
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${!prefix*}
```


### [Pattern Matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching)

例:

```bash
*
```

```bash
prefix*
```

```bash
[[ string == str* ]]
```


### [The Shopt Builtin](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html#The-Shopt-Builtin)

例:

```bash
shopt -s globstar
path/to/**/file
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
$(( n * 2 ))
```


## アットマーク (At sign) @ 記号の意味

### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
"$@"
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
"${!prefix@}"
```

```bash
${!name[@]}
```

```bash
${parameter@Q}
```


### [Pattern Matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching)

例:

```bash
shopt -s extglob
@(pattern-list)
```


### [Bourne Shell Builtins](https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins)

例:

```bash
cd -@
```


## プラス記号 (Plus sign) + 記号の意味

### [Tilde Expansion](https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html#Tilde-Expansion)

例:

```bash
~+
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i++ ))
```

```bash
$(( n + 1 ))
```


### [The Set Builtin](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html#The-Set-Builtin)

例:

```bash
set +o restricted
```


## コンマ (Comma) , 記号の意味

### [Brace Expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html#Brace-Expansion)

例:

```bash
{foo,bar}
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter,pattern}
```

```bash
${parameter,,pattern}
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( x=0, y=0 ))
```


## ハイフン-マイナス (Hyphen-minus) - 記号の意味

### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$-
```


### [Tilde Expansion](https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html#Tilde-Expansion)

例:

```bash
~-
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter:-word}
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i-- ))
```

```bash
$(( n - 1 ))
```


## ドット (Dot, ピリオド) . 記号の意味

### [Brace Expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html#Brace-Expansion)

例:

```bash
{1..10}
```

```bash
{1..9..2}
```


### [Bourne Shell Builtins](https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins)

組み込みコマンド `.`

例:

```bash
. ~/.bashrc
```


## スラッシュ (Slash) / 記号の意味

### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter/pattern/string}
```

```bash
${parameter//pattern/string}
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i /= 2 ))
```

```bash
$(( n / 2 ))
```


## コロン (Colon) : 記号の意味

### [Bourne Shell Builtins](https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins)

組み込みコマンド `:`

例:

```bash
:
```


### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter:-word}
```

```bash
${parameter:=word}
```

```bash
${parameter:?word}
```

```bash
${parameter:+word}
```

```bash
${parameter:offset}
```

```bash
${parameter:offset:length}
```


## セミコロン (Semicolon) ; 記号の意味

### [Lists](https://www.gnu.org/software/bash/manual/html_node/Lists.html#Lists)

書式:

```bash
command1; command2
```


### [Looping Constructs](https://www.gnu.org/software/bash/manual/html_node/Looping-Constructs.html#Looping-Constructs)

例:

```bash
for (( i=1; i <= 10; i++ )); do echo $i; done
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
case "$-" in *i*) echo interactive ;; *) echo not interactive ;; esac
```


## 小なり (Less-than sign) < 記号の意味

### [Redirections](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirections)

例:

```bash
<file
```

```bash
<<EOT
```

```bash
<<<text
```


### [Process Substitution](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html#Process-Substitution)

例:

```bash
<(grep foo file)
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( n < 2 ))
```

```bash
$(( 1 << 8 ))
```


## 等号 (Equals sign, イコール) = 記号の意味

### [Shell Parameters](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html#Shell-Parameters)

例:

```bash
name='foo bar'
```


### [Bash Conditional Expressions](https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html#Bash-Conditional-Expressions)

例:

```bash
[ string1 = string2 ]
```

```bash
[[ string1 == string2 ]]
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( var = 0 ))
```

```bash
(( 0 == 0 ))
```

```bash
(( 1 != 2 ))
```


## 大なり (Greater-than sign) > 記号の意味

### [Redirections](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirections)

例:

```bash
>file
```

```bash
>>file
```


### [Process Substitution](https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html#Process-Substitution)

例:

```bash
>(grep bar)
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( n > 2 ))
```

```bash
$(( 8 >> 1 ))
```


## はてな (Question mark, 疑問符) ? 記号の意味

### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$?
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
$(( n > 2 ? 1 : n ))
```


## 角括弧 (Bracket, ブラケット) [ 記号の意味

### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
[[ ]]
```


### [Bourne Shell Builtins](https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#Bourne-Shell-Builtins)

組み込みコマンド `[`

例:

```bash
[ ]
```


## バックスラッシュ (Backslash) \ 記号の意味

### [Escape Character](https://www.gnu.org/software/bash/manual/html_node/Escape-Character.html#Escape-Character)

例:

`\` (Escape Character)

### [ANSI-C Quoting](https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html#ANSI_002dC-Quoting)

例:

```bash
$'\n'
```


## サーカムフレックス (Circumflex, Hat, ハット) ^ 記号の意味

### [Shell Parameter Expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion)

例:

```bash
${parameter^pattern}
```

```bash
${parameter^^pattern}
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i ^= 0xff ))
```


## アンダースコア (Underscore) _ 記号の意味

### [Special Parameters](https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters)

例:

```bash
$_
```


## バッククォート (Backquote) ` 記号の意味

### [Command Substitution](https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html#Command-Substitution)

例:

```bash
cd `dirname "$0"`
```


## 波括弧 (Curly Bracket) {} 記号の意味

### [Command Grouping](https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html#Command-Grouping)

書式:

```bash
{ list;}
```


### [Brace Expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html#Brace-Expansion)

例:

```bash
cp -a file{,.backup}
```

```bash
for i in {1..10}; do echo $i; done
```


## 縦棒 (Vertical Line、バーティカルライン) | 記号の意味

### [Pipelines](https://www.gnu.org/software/bash/manual/html_node/Pipelines.html#Pipelines)

例:

```bash
grep hoge file | sed s/foo/bar/
```


### [Lists](https://www.gnu.org/software/bash/manual/html_node/Lists.html#Lists)

例:

```bash
command1 || command2
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
case "`uname`" in Linux*|Darwin) echo "Linux or MacOS";; *) echo others ;; esac
```


### [Redirections](https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirections)

例:

```bash
set -o noclobber
echo text >| file.txt
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( i % 3 == 0 || i % 5 == 0 ))
```


## チルダ (Tilde) ~ 記号の意味

### [Tilde Expansion](https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html#Tilde-Expansion)

例:

```bash
~
```


### [Shell Arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html#Shell-Arithmetic)

例:

```bash
(( ~(1 == 2) ))
```


### [Conditional Constructs](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs)

例:

```bash
pattern='^foo bar$'
[[ $parameter =~ $pattern ]]
```

## 後付

### Bashリファレンスマニュアル

- [組み込みコマンド](https://www.gnu.org/software/bash/manual/html_node/Builtin-Index.html#Builtin-Index)
- [予約語](https://www.gnu.org/software/bash/manual/html_node/Reserved-Word-Index.html#Reserved-Word-Index)
- [変数](https://www.gnu.org/software/bash/manual/html_node/Variable-Index.html#Variable-Index)
- [Function Index](https://www.gnu.org/software/bash/manual/html_node/Function-Index.html#Function-Index)
- [概念](https://www.gnu.org/software/bash/manual/html_node/Concept-Index.html#Concept-Index)