# Shell Scripting Basics

Variables, conditions and loops in bash.

```bash
#!/usr/bin/env bash
set -euo pipefail          # stop on errors, undefined vars, pipe failures

name="World"
echo "Hello, $name"
echo "First arg: $1, all args: $@, count: $#"

if [ -f "$file" ]; then echo "exists"; fi   # -f file, -d dir, -e any
if [ "$a" -gt 5 ]; then echo "big"; fi        # -eq -ne -lt -le -gt -ge
if [ -z "$s" ]; then echo "empty"; fi         # -n = not empty

for f in *.txt; do echo "$f"; done
while read -r line; do echo "$line"; done < file

greet() { echo "Hi $1"; }
greet Sam
echo $?                    # exit status of last command
```
