Scripting util curl awk bash y parseos
Scripting util curl awk bash y parseos
Scripting util curl awk bash y parseos
Este post reune patrones utiles para automatizar tareas, probar endpoints HTTP, parsear logs y construir pequenos scripts shell.
curl
1
2
3
4
5
curl -Ik https://app.example.local/
curl -sS https://app.example.local/api/health
curl -X POST https://app.example.local/api \
-H 'Content-Type: application/json' \
-d '{"clave":"valor"}'
awk
1
2
3
awk '{print $1}' fichero.log
awk -F';' '{print $1,$3}' fichero.csv
awk '$9 ~ /^5/ {print $0}' access.log
regex utiles
1
2
grep -E 'ERROR|WARN|FATAL' app.log
grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' app.log | sort -u
parsear logs HTTP
1
2
awk '{print $1}' access.log | sort | uniq -c | sort -nr | head
awk '{print $9}' access.log | sort | uniq -c | sort -nr
plantilla bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash
set -euo pipefail
main() {
local fichero="${1:-}"
if [[ -z "$fichero" ]]; then
printf 'Uso: %s <fichero>\n' "$0" >&2
exit 1
fi
grep -E 'ERROR|WARN' "$fichero"
}
main "$@"
This post is licensed under CC BY 4.0 by the author.