> For the complete documentation index, see [llms.txt](https://cheatsheet.mrw0l05zyn.cl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cheatsheet.mrw0l05zyn.cl/linux-unix/busqueda-y-manipulacion-de-texto.md).

# Búsqueda y manipulación de texto

## grep

```shell
grep <word> <file>
# Expresiones regulares
grep -Ei "<word-1>|<word-2>|<word-3>" <file>
# Invertir filtro
cat /etc/passwd | grep -Eiv "/usr/sbin/nologin|/bin/false"
```

## sed

```shell
echo "hack the world" | sed 's/world/planet/'
```

## cut

```shell
cut -d ":" -f 1 /etc/passwd
```

## awk

```shell
echo "uno-dos-tres" | awk -F "-" '{print $1, $3}'
```

## tr

```shell
tr --delete '\n' < <file>
tr -d '\n' < <file>
tr -d '[[:space:]]' < <file>
```
