Newer
Older
```
bash defines the following built-in commands: :, ., [, alias, bg, bind, break, builtin,
case, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable, eval,
exec, exit, export, fc, fg, getopts, hash, help, history, if, jobs, kill, let, local,
logout, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source,
suspend, test, times, trap, type, typeset, ulimit, umask, unalias, unset, until, wait,
while.
```
They are built-in for performance reasons.
There are many more commands available on your machine. Unix machines have several hundreds of different commands.
A good place to look at them is ([http://ss64.com/mac](http://ss64.com/mac) or [http://ss64.com/bash](http://ss64.com/bash).
**No worries! As most of people we only need to use a very small subset of those commands.**
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
## How commands works
```bash
command [ -option ] [ arguments ]
```
* [ ] means this is optional (e.g. `ls` vs `ls -l`)
* **Option** only modify the behavior of the command. It starts with `-` (or `--` for long option)
* **Argument** controls the output of the command. It specifies a target for the command.
It is possible to execute several commands in one line using **;** in between commands:
```bash
command1 ; command2
```
It is possible to save the output of a command in a variable:
```bash
var=$(command)
```
### Input/Output of commmands
Commands can take different arguments:
** Nothing **
```bash
ls
```
** String **
```bash
echo hello world
```
** File **
```bash
cat file_input
```
** A stream **
What is a stream?
explanation here
```bash
cat file_input | tr a-z A-Z
```
It is possible to send the output (STDOUT) of a command as input (STDIN) of another using **|**:
```bash
command1 | command2
```
It is possible to save/send the output of a command in a file:
```bash
# overwrite file if already exists
command > file
# append file if already exists
command >> file
```
/!\\ commmands that take an input either from a **file** of from **STDIN**: grep, sed, cat, head, sort, wc, etc.
/!\\ commmands that **never read STDIN**: ls, cp, mv, date, who, pwd, echo, cd, etc.
/!\\ commmands that **read only STDIN**: tr