2 Bash
Caffeine Fueled edited this page 2025-10-01 18:58:35 +00:00

Running multiple commands at once

{ cmd() { printf "\n# %s\n" "$*"; "$@"; }; \
    cmd dig MX example.com +short; \
    cmd dig TXT example.com +short; \
    cmd dig TXT _dmarc.example.com +short; \
    cmd dig TXT *._domainkey.example.com +short; \
    } 2>&1

Looping through commands with list of items

while read ip; do
  sudo ufw allow in on eth0 from $ip to 192.0.2.0/24 port 80 proto tcp
  sudo ufw allow in on eth0 from $ip to 192.0.2.0/24 port 443 proto tcp
done < whitelist.txt

#!/bin/bash

while read domain; do
    echo "$domain"
    dig MX $domain +short
    dig TXT $domain +short
    dig TXT _dmarc.$domain +short
    dig TXT *._domainkey.$domain +short
    echo ""
done < domain-list.txt

Show counter for unique lines

sort file.txt | uniq -c | sort -nr

Curl - Simple API call

curl -X POST http://localhost:8000/api/run1/ \
  -H "Authorization: Bearer 9d207bf0-10f5-4d8f-a479-22ff5aeff8d1" \
  -d "host_a,is ok"