Tool.Yun
Geliştiriciler için kullanışlı araçlar
ActiveDirectory LDAP özellik arayıcısı
DMARC Rapor Analizcisi
DNS Test Cihazı
DNS Yayılım Test Cihazı
Direnç Hesaplayıcısı
Dosya Türü Algılayıcı
E-posta Ayrıştırıcısı
EMV TLV kod çözücü
ETH İşlem Kod Çözücü
GZip/Deflate dönüştürücü
Geri Dönen E-posta Ayrıştırıcısı
HTTPS Test Cihazı
Hassas veri maskeleyici
Hex Kodlayıcı/Kod Çözücü
Kar Tanesi Kimlik Çıkarıcı
Kayan nokta sayı dönüştürücü
Keycode bilgisi
Kısa URL Genişletici
MIME Kodlama Dönüştürücü
Metin Karakter Seti Algılayıcı/Kod Çözücü
MongoDB ObjectId Dönüştürücü
Nmap Komut Oluşturucu
Orta-Endian Dönüştürücü
Outlook MSG Ayrıştırıcısı
Outlook Safelink kod çözücü
Parke dosyaları Okuyucu
RJ45 Cat6 Kablolama Hızlı Referans Kılavuzu
SMART Raw Dönüştürücü
Seri Port Konsolu
SharePoint Paylaşım URL Kod Çözücü
TCPDump Oluşturucu
URL Oluşturucu
URL ayrıştırıcısı
Çerez Ayrıştırıcısı
Ölü Piksel Test Cihazı
键盘测试器
ARPA Kod Çözücü
Apache LogRotate Oluşturucu
BIMI DNS Oluşturucu
Chmod hesaplayıcısı
Cloudflare DNS/RDAP Sorguları
Crontab oluşturucu
Curl Komut Üreticisi
DKIM DNS Oluşturucu
DMARC DNS Oluşturucu
DNS Sorguları
DNSBL Denetleyicisi
FStab Jeneratörü
Görsel Alt Ağ Hesaplayıcı
HAS Dezenfektan
HDD hesaplayıcısı
HTAccess oluşturucu
Htpasswd/htaccess üreteci
IP Adresim
IP Alt Ağları Hariç Tutma Hesaplayıcısı
IP Coğrafi Konum
IPv4 Alt Ağ Listeleyicisi
IPv4 adres dönüştürücü
IPv4 alt ağ hesaplayıcısı
IPv4 aralık genişletici
IPv4-6/IPRange/CIDR, IPRange/CIDR/IPMask'ta
IPv4/6 Aralığı CIDR(ler) Hesaplayıcısı
IPv6 ULA üreteci
IPv6 adres dönüştürücü
IPv6 alt ağ hesaplayıcısı
Iptables Üreticisi
Ipv4/6 CIDR - IP Aralığı Hesaplayıcısı
Kabuk Komutları Biçimlendiricisi
Kabuk Komutları Doğrusallaştırıcı
Kapatma Komutu Oluşturucu
MAC Adresi Dönüştürücü
MAC adresi araması
MAC adresi üreteci
Mikrofon Test Cihazı
Nginx biçimlendirici
Option43 jeneratörü
PTR DNS Oluşturucu
Ping
Port Numaraları
Punycode Dönüştürücü
RAID Güvenilirlik Hesaplayıcısı
RAID Hesaplayıcı
Rastgele port oluşturucu
Rsync Üreticisi
SIP Yetkilendirmesi
SPF DNS oluşturucu
TCP/UDP Port Test Cihazı
Tam Sayılardan IPv4/IPv6'ya
Temel kimlik doğrulama oluşturucu
UFW Komut Üreticisi
Veri Aktarım Hızı Hesaplayıcı
WPA PSK üreteci
Websocket testi
Whois Denetleyicisi
Wireguard Yapılandırma Oluşturucu
X-VR-SpamCause Kod Çözücü
ZPOOL RAID hesaplayıcısı
ZPool Hile Sayfası
Zxcvbn Şifre Gücü
firewalld komut satırı oluşturucu
tools.restic-command-generator.name
tools.url-redirection-checker.name
Çoklu bağlantı indirici
Şifre gücü analizi
Barkod Okuyucu
Barkod üreteci
GTIN Doğrulayıcı
QR Kod çözücü
QR Kod üreteci
QR İletişim Bilgisi Oluşturucu
WiFi QR Kodu üreteci
tools.epc-qrcode-generator.name
AGE Kriptografisi
Ansible Vault şifreleme şifresini çözme
Argon2 Karıştırıcı
Bcrypt
Bech32 Kodlayıcı/Kod Çözücü
CRC hesaplayıcısı
CSR Üreticisi
Dosya Karıştırıcı
ECDSA anahtar çifti oluşturucu
Ed25519 anahtar çifti üreteci
Hmac oluşturucu
JWT Jeneratörü
JWT ayrıştırıcısı
Jasypt Dize Şifrelemesi
Karma metin
Metni Şifrele/Çöz
Niceware Baytlarını Parolaya Dönüştürme
PGP Dosya Şifrelemesi
PGP anahtar üreticisi
PGP şifrelemesi
Paseto/PASERK Kamu/Özel
Paseto/PASERK Yerel
RSA anahtar çifti üreteci
RSA şifrelemesi
RSA/DSA/ECDSA İmzalayan ve Doğrulayan
SAML Ayrıştırıcısı
SSL Sertifika dönüştürücü
Sertifika/Anahtar ayrıştırıcısı
Shamir'in Gizli Paylaşımı
X509 sertifika oluşturucu
Base64 Hex dizi kodlayıcı/kod çözücü
Base64 dosya dönüştürücü
Base64 metin şifreleyici/çözücü
CSV'den Veriye
Coğrafi Koordinat Dönüştürücü
E-posta normalleştirici
Enerji Tüketimi ve Gider Bilgisayarı
Excel'den veriye
Metinden UTF-8 ikilisine
Metinden Unicode'a
Roma rakamı dönüştürücü
Tam sayı taban dönüştürücü
Torrent'ten Mıknatısa
ULID üreteci
Unicode Karakterlerini Java Varlıklarına Dönüştürücü
Veri Depolama Birimi dönüştürücü
dBm mW Dönüştürücü
Çevre Değişkenleri Biçim Dönüştürücü
Çok Birim Dönüştürücü
Özellikler dönüştürücü
Amortisman Hesaplayıcısı
Alan Birimleri Dönüştürücü
Aydınlatma Dönüştürücü
Açı Birimleri Dönüştürücü
Basınç Birimleri Dönüştürücü
Enerji Birimleri Dönüştürücü
Fitness Bilgisayarı
Frekans Dönüştürücü
Güç Dönüştürücü
Gıda Enerji Dönüştürücü
Hacim Akış Hızı Dönüştürücü
Hacim Birimleri Dönüştürücü
Hız Dönüştürücü
Hızlanma Dönüştürücü
Kuvvet Birimleri Dönüştürücü
Kütle Birimleri Dönüştürücü
SI Önekleri Dönüştürücü
Sıcaklık dönüştürücü
Uzunluk Birimleri Dönüştürücü
ANSI Kaçış Test Cihazı
API Testleri
Açık grafik meta üreteci
Bukle Dönüştürücü
CSS/JS Güzelleştirme ve Küçültme
Cli komut düzenleyicisi
Django Gizli Üreticisi
Dosya Bölücü
Favicon Oluşturucu
GitIgnore Oluşturucu
Gitattributes Generator
HEX Dosya Dönüştürücü
Javascript Gizleyici
Javascript Güzelleştirici
Javascript Unobfuscator/Unpacker
Json'dan Protobuf'a
Json'dan SQL'e INSERT
Json'dan Typescript'e
K6 Yük Testi Komut Dosyası Oluşturucu
Kod/Komut Dosyası Vurgulayıcı
Mailto Oluşturucu
Picomatch Test Cihazı
Pomodoro Zamanlayıcısı
SQL Küçültücü
SQL Parametreleri Oluşturucu
SQL güzelleştirici
Stacktrace daha güzel
Swagger kullanıcı arayüzü test kullanıcısı
Teklif Dönüştürücü
Veri Sahtekarı
Veritabanı Bağlantı Dizesi Oluşturucu
Veritabanı Oluşturma Aracı
Veritabanı Tablosu Oluşturucu
İp Kaçışı
EXIF'i kaldır
Filigran
GIF'ten MP4'e
Görüntü Arka Planını Kaldır
Görüntü EXIF/Meta Veri/GPS/JPEG Kalite okuyucu
Görüntü Formatları Dönüştürücü
Görüntü Karşılaştır
Görüntü Renk Çeviricisi
Görüntü yeniden boyutlandırıcı
Görüntüden SVG'ye (potrace)
Görüntüyü ve PDF'yi OCRize edin
HEIC Dönüştürücü
ICO/PNG dönüştürücü
Kamera kaydedici
Resmi kırp
SVG Önizleyici
Bash Hile Sayfası
CSS Seçiciler Hile Sayfası
Docker Compose hile sayfası
Docker Hile Sayfası
Docker SWARM hile sayfası
Dockerfile hile sayfası
Ekran Komutları Hızlı Referans Kılavuzu
Git Semantik Commit Hile Sayfası
Git hatırlatma notu
JSONPath Sözdizimi Hile Sayfası
Jq Hile Sayfası
K8s Hile Sayfası
Markdown Hile Sayfası
Nano Hile Sayfası
Nginx Hile Sayfası
PowerShell Hızlı Başvuru Kılavuzu
Regex hile sayfası
Sed hile sayfası
Tmux Komutları Hızlı Referans Kılavuzu
VIM Hile Sayfası
XPath Sözdizimi Hile Sayfası
Yaygın Regex Hile Sayfası
Zellij Komut Hile Sayfası
chmod Komut Hile Sayfası
CSV'den JSON'a
JS'den JSON'a dönüştürücü
JSON Birleşmesi
JSON Düzleştirici/Düzleştirmeyi Kaldırıcı
JSON Editörü
JSON Linter
JSON farkı
JSON güzelleştirme ve biçimlendirme
JSON küçültme
JSON nesneye
JSON sıralama ustası
JSON to CSV
JSON to Go
JSON'dan .env'ye
JSON'dan C#'a
JSON'dan JS'ye dönüştürücü
JSON'dan Java Varlığına
JSON'dan MessagePack'e
JSON'dan TOML'a
JSON'dan TS'ye
JSON'dan Verilere
JSON'dan XML'e
JSON'dan YAML'ye dönüştürücü
Jq/JSONPath Test Cihazı
Json Boyut Analizcisi
Json Kaçış/Kaçış Kaldırıcı
Json Sorgusu
Json dize dönüştürücü
Json'dan PHP Dizisine
Json'dan PHP Koduna
Json'dan Python'a
Json'dan SQL'e DDL
Json'dan Şemaya
Mesaj Paketini JSON'a Dönüştür
ObjGen'den JSON'a
PHP Dizisini JSON'a Dönüştürme
tools.json-patch.name
BIP39 şifre oluşturucu
Diceware Şifre Oluşturucu
NanoID üreteci
OTP kod üreteci
Parola Üreticisi
Pin Kodu Üreticisi
Rastgele sayı üreteci
Sayı üreteci
Token Oluşturucu
UUID dönüştürücü
UUID üreteci
Docker Compose Doğrulayıcı
Docker Compose Format Dönüştürücü
Docker Compose'dan Docker run dönüştürücüsüne
Docker Compose'dan Quadlet'lere
Docker Compose'u .env dosyasına dönüştürme
Docker Compose'u Kubernetes'e dönüştürme
Docker Görüntü İndirici
Docker Pangolin Etiketleri
Docker çalıştırma ve Docker oluşturma dönüştürücüsü
Docker'ı Docker'a denetle
Docker, Kubernetes'e çalıştırılıyor
Docker, Quadlet'lere koşuyor
Dockerfile Etiket Oluşturucu
Kubernetes RBAC Oluşturucu
Traefik Docker Compose Maker
Bahşiş hesaplayıcı
Matematik Formatları Dönüştürücü
Matematik OCR
Matematiksel ifade hesaplayıcı
Trigonometrik/Denklem Eğrisi Görselleştirici
İkili Hesap Makinesi
Fal çarkı
Kart Seçici
Madeni Para Atma Makinesi
Zar Atıcı
HTML'den PDF'ye
PDF Birleştirici
PDF Doğrusallaştır/HızlıWeb
PDF Metin Çıkarıcı
PDF Sayfa Çıkarıcı
PDF Sıkıştırıcı
PDF imza denetleyicisi
PDF Şifreleme
PDF Şifresini Çöz ve Kilidini Aç
TOML Linter
TOML'den JSON'a
TOML'den YAML'ye
Cron/Hafta İçi Alarmı
ETA hesaplayıcı
Geri sayım
Gün Hesaplayıcısı
Hafta Sayıları Dönüştürücü
Hangi Gün?
ICAL Dosya Ayrıştırıcısı
ICAL Jeneratörü
Kronometre
Saat Dilimi Dönüştürücü
Süre Hesaplayıcısı
TTL hesaplayıcısı
Tarih+Süre Hesaplayıcısı
Tarih-saat dönüştürücü
Zaman Alarmı
iCal Birleşmesi
Cron İfade Oluşturucu
BMI Hesaplayıcı
Döviz Dönüştürücü
IBAN doğrulayıcı ve ayrıştırıcı
IES Aydınlatma Yönergeleri
ISBN Doğrulayıcı ve Ayrıştırıcı
ISO 3166 Ülke Kodları Arama Aracı
ISO 639 Arama Aracı
KDV Numaraları Doğrulayıcı
Kabuk Komutlarını Açıklayın
Koşu Hızı Hesaplayıcı
Kredi Kartı Denetleyicisi
Luhn Doğrulayıcı
RMB Büyük Harf Dönüştürücü
SLA hesaplayıcısı
Takvim Dönüştürücü
Telefon ayrıştırıcı ve biçimlendirici
Unicode Arama
Yazılım lisans uyumluluğu
Çevrimiçi Sözlük
CSS Birim Dönüştürücü
CSS Gradyan Oluşturucu
CSS XPath Dönüştürücü
CSS güzelleştirici
Cihaz bilgileri
Görüntüden CSS'ye
HTML Güzelleştirici
HTML Küçültücü
HTML WYSIWYG düzenleyici
HTML temizleyici
HTML varlıklarından kaçış
HTML'den XHTML'e
HTML'den veriye
HTTP durum kodları
Kullanıcı aracı ayrıştırıcısı
MIME türleri
REM Piksel dönüştürücü
Renk Kontrast Denetleyicisi
Renk dönüştürücü
Renk Çemberi
SVG placeholder oluşturucu
Slugify dizesi
URL Metin Arama Parçası Oluşturucu
URL Temizleyici
URL Yakalayıcı
URL biçimli dizeleri kodla/kodunu çöz
UTM URL Oluşturucu
ObjGen'den HTML'ye
XML Linter
XML biçimlendirici
XML'den JSON'a
XPath Test Cihazı
XSLT test cihazı
YAML Birleşmesi
YAML Düzleştirici/Düzleştirici
YAML güzelleştirici
YAML'den JSON'a dönüştürücü
YAML'den TOML'ye
AI için dosyaları paketle
AI İstemi Ayırıcı
ASCII Art Metin Oluşturucu
Akıllı Metin Değiştirici ve Satır Sonlandırıcı
Alıntı Oluşturucu
Denizkızı ihracatçısı
Dize karartıcı
Emoji seçici
Farklı Kelimeler
GPT Token Kodlayıcı/Kod Çözücü
GPT Token Tahmincisi
Görüntüden ASCII Sanatına
HTML'den metin çıkar
I ve L Denetleyicisi
JSON'dan TOON'a
Kasa dönüştürücü
Klasör Yapısı Diyagramı
Klavye Düzeni Dönüştürücü
Levenshtein Hesap Makinesi
Liste dönüştürücü
Listeleri Karşılaştır
Merhaba jeneratör.
Metin farkı
Metin istatistikleri
Metin Çevirmeni
Metinden Unicode Adlarına
Mors Kodu Dönüştürücü
NATO alfabesine metin
RSVP Okuyucusu
Rastgele Satır Seçici
Regex Test Cihazı
Rün dönüştürücü
Sed Komut üreteci
Sekme tuşuyla boşluklara geçin
Sosyal Bağlantı Paylaşıcısı
TOON'dan JSON'a
Unicode Biçimlendirici
Unicode'dan GSM-7'ye
Yazı Tipi Karşılaştır
Yinelenen Satır Bulucu
Zalgo Jeneratörü/Banner
Benchmark oluşturucu
Coğrafi mesafe hesaplayıcısı
En Boy Oranı Hesaplayıcısı
Yüzdelik Hesaplayıcı
Epub'dan Markdown'a
Html'den Markdown'a
Markdown Editörü
Markdown Farkı
Markdown Lorem Ipsum
Markdown Tablo Güzelleştirici
Markdown Tablosu Oluşturucu
Markdown olarak yapıştır
Markdown toc oluşturucu
Markdown önizlemesi
Markdown'dan DOCX'e
Markdown'dan HTML'ye
Markdown'dan Metne
Markdown'dan veriye
tools.markdown-format-converter.name

Bash Hile Sayfası

Bash'in yaygın komutları

Bash is the default shell on most Linux systems and the language of most glue scripts. This sheet covers the interactive shortcuts, the syntax you forget between scripts, and the safety flags worth putting at the top of every file.

#!/usr/bin/env bash
set -euo pipefail

⌨️ Keyboard Shortcuts

KeysDoes
Ctrl+A / Ctrl+EJump to the start / end of the line
Ctrl+B / Ctrl+FBack / forward one character
Alt+B / Alt+FBack / forward one word
Ctrl+U / Ctrl+KCut to the start / end of the line
Ctrl+WCut the word before the cursor
Alt+DCut the word after the cursor
Ctrl+YPaste back what you last cut
Ctrl+T / Alt+TSwap the last two characters / words
Alt+.Insert the last argument of the previous command
Ctrl+LClear the screen
Ctrl+RSearch the history backwards
Ctrl+GAbort the history search
Ctrl+CInterrupt the running command
Ctrl+DEnd of input — logs out of an empty prompt
Ctrl+ZSuspend the running command
Ctrl+S / Ctrl+QFreeze / resume terminal output
Alt+U / Alt+LUpper-case / lower-case to the end of the word

🕰 History

# the last few hundred commands
history

# run command number 42
!42

# run the last command again, or the last one starting with 'ssh'
!!
!ssh

# the last argument of the previous command — also Alt+.
!$

# every argument of the previous command
!*

# re-run the last command with a substitution
^old^new

# forget a command you would rather not keep
history -d 42

# do not record commands that start with a space, and drop duplicates
export HISTCONTROL=ignoreboth
export HISTSIZE=10000 HISTFILESIZE=20000

📁 Files & Directories

# list: long, human sizes, hidden files, newest last
ls -lhAtr

# tree view of a directory
tree -L 2

# copy, move, delete
cp -r src/ dest/
mv old new
rm -rf directory

# create nested directories in one go
mkdir -p project/{src,test,docs}

# symbolic and hard links
ln -s /path/to/target linkname
ln target hardlink

# where is a file, and what is it?
find . -name '*.log' -mtime -7
find . -type f -size +100M
locate nginx.conf
which python3
type -a ls
file archive.bin
stat report.pdf

# disk usage: this directory, and the filesystem
du -sh *
du -h --max-depth=1 | sort -h
df -h

# archives
tar czf backup.tar.gz directory/
tar xzf backup.tar.gz
zip -r archive.zip directory/
unzip archive.zip

🔎 Text & Search

# grep: recursive, line numbers, case-insensitive
grep -rni "pattern" .

# only the matching part, or only the file names
grep -o 'v[0-9.]*' file
grep -rl "TODO" src/

# invert, count, context
grep -v "debug" app.log
grep -c "error" app.log
grep -B2 -A2 "exception" app.log

# head, tail, follow
head -20 file
tail -f /var/log/syslog

# columns, sorting, counting
cut -d',' -f1,3 data.csv
sort -u names.txt
sort -k2 -n scores.txt
uniq -c sorted.txt
wc -l file

# the classic: what are the top ten IPs in this log?
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head

# replace across many files
sed -i 's/old/new/g' *.conf

# translate or delete characters
tr 'a-z' 'A-Z' < file
tr -d '\r' < dos.txt > unix.txt

# split a stream: to a file and onward down the pipe
command | tee output.log | grep error

# build command lines from input
find . -name '*.py' | xargs wc -l
find . -name '*.tmp' -print0 | xargs -0 rm

🖧 System & Network

# who and where am I
whoami; hostname; uname -a; uptime

# processes
ps aux | grep nginx
pgrep -a node
top
htop

# memory and load
free -h
vmstat 1 5

# what is listening, and what has this file open
ss -tulpn
lsof -i :8080
lsof /var/log/app.log

# connectivity
ping -c 4 example.com
traceroute example.com
dig example.com +short
ip addr show
curl -I https://example.com

# transfer files
scp file user@host:/path/
rsync -avz --progress src/ user@host:/dest/

# remote shell, with a tunnel
ssh user@host
ssh -L 8080:localhost:80 user@host

# services and logs (systemd)
systemctl status nginx
journalctl -u nginx -f --since "1 hour ago"

📦 Variables

# assignment: no spaces around the =
name="value"

# only for this one command
DEBUG=1 ./script.sh

# export to child processes
export PATH="$HOME/bin:$PATH"

# read input from the user
read -p "Name: " name
read -rs -p "Password: " pass

# command substitution
today=$(date +%F)

# arithmetic
count=$(( count + 1 ))
let "n = 5 * 3"

# read-only and integer variables
declare -r VERSION=1.0
declare -i counter=0
VariableHolds
$0The name of the script
$1 … $9Positional arguments
$#How many arguments were passed
$@All arguments, each one quoted separately
$*All arguments as a single word
$?Exit status of the last command
$$PID of the current shell
$!PID of the last background job
$_Last argument of the previous command
$HOME $USER $PWD $OLDPWDThe usual environment
$RANDOMA random integer
$LINENOThe current line number — handy in traps

🔤 Parameter Expansion

ExpansionResult
${var:-default}default when var is unset or empty
${var:=default}The same, and assigns it
${var:?message}Abort with message when unset — great for required arguments
${var:+value}value only when var is set
${#var}The length of the value
${var:offset:length}A substring
${var#pattern}Strip the shortest match from the start
${var##pattern}Strip the longest match from the start — ${path##*/} is basename
${var%pattern}Strip the shortest match from the end — ${file%.txt} drops the extension
${var%%pattern}Strip the longest match from the end
${var/old/new}Replace the first match
${var//old/new}Replace every match
${var^^} / ${var,,}Upper-case / lower-case the whole value
path="/var/log/app.log"
echo "${path##*/}"    # app.log
echo "${path%/*}"     # /var/log
echo "${path%.log}"   # /var/log/app

📚 Arrays

# indexed arrays
fruits=(apple banana cherry)
fruits[3]="date"

echo "${fruits[1]}"       # banana
echo "${fruits[@]}"       # every element
echo "${#fruits[@]}"      # how many elements
echo "${!fruits[@]}"      # the indexes
echo "${fruits[@]:1:2}"   # a slice

for fruit in "${fruits[@]}"; do
  echo "$fruit"
done

# associative arrays (bash 4+)
declare -A color
color[apple]="red"
color[banana]="yellow"

echo "${color[apple]}"
for key in "${!color[@]}"; do
  echo "$key is ${color[$key]}"
done

🧪 Tests & Conditions

Use [[ ... ]] in bash — it handles empty variables and patterns far better than the old [ ... ].

FilesTrue when
-e fileIt exists
-f fileIt exists and is a regular file
-d fileIt exists and is a directory
-L fileIt is a symbolic link
-s fileIt exists and is not empty
-r -w -xYou can read / write / execute it
-O fileYou own it
f1 -nt f2f1 is newer than f2 (-ot for older)
StringsTrue when
-z "$s"The string is empty
-n "$s"The string is not empty
"$a" == "$b"They are equal (= also works)
"$a" != "$b"They differ
"$a" < "$b"Sorts before, in the current locale
"$s" == pre*Glob match — unquoted right-hand side
"$s" =~ ^re$Regex match, captures land in $BASH_REMATCH
NumbersMeaning
-eqEqual
-neNot equal
-ltLess than
-leLess than or equal
-gtGreater than
-geGreater than or equal
if [[ -f "$config" && -r "$config" ]]; then
  echo "readable"
elif [[ -d "$config" ]]; then
  echo "that is a directory"
else
  echo "missing"
fi

# arithmetic comparison reads more naturally in (( ))
if (( count > 10 )); then echo "plenty"; fi

🔀 Flow Control

# for over a list, a glob, or a range
for name in alice bob; do echo "$name"; done
for f in *.log; do gzip "$f"; done
for i in {1..10}; do echo "$i"; done
for (( i = 0; i < 10; i++ )); do echo "$i"; done

# while and until
while read -r line; do echo "$line"; done < input.txt
until ping -c1 host &>/dev/null; do sleep 5; done

# case
case "$1" in
  start)   echo "starting" ;;
  stop)    echo "stopping" ;;
  restart) echo "restarting" ;;
  *)       echo "usage: $0 {start|stop|restart}"; exit 1 ;;
esac

# select builds a numbered menu
select choice in build test deploy; do
  echo "you picked $choice"
  break
done

# loop control
continue   # skip to the next iteration
break      # leave the loop

🧰 Functions

greet() {
  local name="${1:?name required}"
  local greeting="${2:-Hello}"
  echo "$greeting, $name!"
  return 0
}

greet "World"
greet "World" "Good morning"

# capture the output, and check the status
message=$(greet "World")
if ! greet; then echo "greet failed"; fi

# make a function available to subshells
export -f greet

➡️ Redirection

SyntaxDoes
> fileSend stdout to a file, replacing it
>> fileAppend stdout to a file
2> fileSend stderr to a file
2>&1Send stderr wherever stdout is going
&> fileSend both to a file (bash)
> file 2>&1The portable form of the same
< fileRead stdin from a file
<<EOF … EOFHere-document
<<-EOF … EOFHere-document, leading tabs stripped
<<< "string"Here-string
|Pipe stdout into the next command
|&Pipe stdout and stderr
> /dev/null 2>&1Discard everything
<(command)Process substitution — a command as a file
tee fileWrite to a file and pass the stream on
# a heredoc, expanded
cat <<EOF > config.ini
host=$HOSTNAME
port=8080
EOF

# a heredoc, literal (quoted delimiter)
cat <<'EOF' > script.sh
echo "$HOME is not expanded here"
EOF

# compare the output of two commands without temporary files
diff <(sort a.txt) <(sort b.txt)

⚙️ Jobs & Processes

# run in the background, and list the jobs
long_task &
jobs

# bring back to the foreground, or resume in the background
fg %1
bg %1

# Ctrl+Z suspends the foreground job

# survive logout
nohup ./script.sh > out.log 2>&1 &
disown -h %1

# wait for background jobs
wait
wait $!

# signals
kill 1234
kill -9 1234
kill -TERM %1
pkill -f "node server.js"

# give a command a deadline
timeout 30s ./slow_task.sh

# clean up on exit, whatever happens
trap 'rm -f "$tmpfile"' EXIT
trap 'echo interrupted; exit 130' INT TERM

🛡 Safe Scripting

#!/usr/bin/env bash
# -e  exit on any failing command
# -u  treat unset variables as an error
# -o pipefail  a pipeline fails if any stage fails
set -euo pipefail

# make word splitting predictable
IFS=$'\n\t'

# always quote expansions
cp "$src" "$dest"

# check the syntax without running anything
bash -n script.sh

# trace every command as it runs
bash -x script.sh
set -x; risky_command; set +x

# a more informative trace prefix
export PS4='+ ${BASH_SOURCE}:${LINENO}: '

# report where a script died
trap 'echo "failed at line $LINENO with status $?" >&2' ERR

# and lint it before it reaches anyone else
shellcheck script.sh

⚠️ set -e has surprising corners: it does not fire inside if, &&, || or command substitutions used in assignments. It is a seatbelt, not autopilot — still check what matters explicitly.

🎨 Colours

Escape sequences take the form \033[<style>;<colour>m, and \033[0m resets. \e and \x1B are the same character as \033.

ColourForegroundBrightBackground
Black309040
Red319141
Green329242
Yellow339343
Blue349444
Magenta359545
Cyan369646
White379747
StyleCodeStyleCode
Reset0Underline4
Bold1Blink5
Dim2Reverse7
RED='\033[0;31m'
GREEN='\033[0;32m'
BOLD='\033[1m'
RESET='\033[0m'

echo -e "${GREEN}ok${RESET} — ${RED}${BOLD}failed${RESET}"

# only colourise when stdout is a terminal
if [[ -t 1 ]]; then RED='\033[0;31m'; RESET='\033[0m'; else RED=''; RESET=''; fi

💡 Tips

# aliases and functions belong in ~/.bashrc
alias ll='ls -lhA'
alias gs='git status -sb'
mkcd() { mkdir -p "$1" && cd "$1"; }

# reload the config after editing it
source ~/.bashrc

# brace expansion saves a lot of typing
cp config.yaml{,.bak}
mkdir -p src/{components,utils,tests}

# repeat the previous command as root
sudo !!

# go back to the previous directory
cd -

# run something regardless of the current directory
(cd /tmp && ./task.sh)

# time a command, and keep a transcript of a session
time ./build.sh
script session.log

📚 Resources

  • GNU Bash manual
  • ShellCheck — lints your scripts
  • Bash Pitfalls
  • Google Shell Style Guide
  • explainshell — break down any command line