# Variables & Conditionals — Linux

Source: https://www.geekswithgeeks.com/en/linux/linux-bash-variables-conditionals

> Storing values and branching in bash.

## Variables

No spaces around `=`. Read a variable's value with `$name`.

```bash
name="Bob"
count=3
echo "$name has $count files"
```

Output:

```
Bob has 3 files
```

## if / else

Test expressions go inside `[ ]` (spaces matter). `-f` checks a file exists.

```bash
if [ -f "notes.txt" ]; then
    echo "File exists"
else
    echo "Not found"
fi
```

Output:

```
File exists
```
