Add Bash
parent
67088062dd
commit
5185476d06
1 changed files with 37 additions and 0 deletions
37
Bash.md
Normal file
37
Bash.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
## Running multiple commands at once
|
||||
```bash
|
||||
{ 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
|
||||
```bash
|
||||
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
|
||||
```
|
||||
---
|
||||
|
||||
```bash
|
||||
#!/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
|
||||
```bash
|
||||
sort file.txt | uniq -c | sort -nr
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue