It’s like a “translator” that lets you tell your computer what to do using only text. You open a terminal window, type a command, and the shell sends it to the OS. Then the computer does the job and shows you the result.
パソコンに「文字だけで指示を出すための通訳さん」です。画面に文字の窓(ターミナル)を開いて、コマンド(命令文)を打つと、ShellがOSに伝えて実行し、結果を返してくれます。
.sh などのファイルに命令を並べ、自動実行する顔/bin/ls など実行ファイル)cd などシェル内蔵)PATH に並ぶフォルダからコマンドを探します。help(ビルトインのヘルプ)や man(マニュアル)で自己解決しやすいのも特長。例:type ls(それが外部コマンドか、エイリアスか等の正体を表示)
例:echo $PATH(探す場所の一覧を表示)
ふつうのPC操作を“高速・大量・自動”に持っていく力が身につきます。
cd, ls, mkdir, rm, cp, mv, findfind ./logs -name "*.log" -mtime -1grep, sed, awk, cut, sort, uniq, tr, xargsgrep "ERROR" app.log | cut -d' ' -f1 | sort | uniq -c | sort -nr|> >> <curl -s https://example.com | wc -l > lines.txt変数・条件分岐・繰り返し・関数・引数処理・終了コードの扱い
エイリアス・補完・プロンプト・履歴の活用、.bashrc / .zshrc などの設定
alias gs='git status'ps, top, htop, jobs, fg, bg, kill, nicesleep 300 &(裏で5分待機)→ jobs → fg で前面へsudo, chmod, chown, umask、ファイル所有者・権限の意味
chmod 600 id_rsa(秘密鍵を自分だけ読めるように)tar, gzip, zip, unzip, scp, rsync
tar -czf backup_$(date +%F).tar.gz ./projectcurl, wget, ping, dig, nccurl -s https://api.example.com/items | jq .[] | wc -lapt, dnf, pacmanbrewsudo apt install jqsystemctl, journalctl, cron, logrotatecrontab -e で毎日3:00にバックアップGit操作・ブランチ運用、Dockerビルド、GitHub Actionsのトリガ、AWS/Azure/GCPのCLI活用
巨大ファイルでも“待てる速度”で集計やフィルタが可能
csvcut, csvgrep, mlr (miller), jqどの環境で?
Git Bash
pwd
ls
cd ..
ls -la
Git Bash
grep -R "TODO" ./project | wc -l
Git Bash
curl -s https://example.com | wc -l
拡張子.logのサイズ上位10件
Git Bash
cat <<'EOF' > top-logs.sh
#!/usr/bin/env bash
set -eu
find . -name "*.log" -type f -print0 \
| xargs -0 ls -l \
| sort -nr -k5 \
| head -n 10
EOF
chmod +x top-logs.sh
./top-logs.sh
pwd, ls, cd, cat, less--help, man, helprm -rfは打たない、ワイルドカード*は慎重に、sudoは最小限リダイレクト(>, >>, <)、パイプ(|)
grep, cut, sort, uniq, tr, xargsグロブ(*.txt)とクォート("…", '…')の違い
if/for、関数、引数($1 など)、exitコード、trapset -euo pipefail、一時ファイル、mktempcronで定期実行、systemctl/journalctlでサービス・ログchmod/chown/umask)、SSH公開鍵、scp/rsync.bashrc/.zshrc、エイリアス、補完、プロンプト)sed/awkでの高度なテキスト処理jq/miller、プロファイリングrm は -i(確認つき)を検討。パスはタブ補完で誤字防止。echo *.log で展開結果を見てから本番。sudoは必要最小限"$var" を基本形に。rsync -n など“実行せずに差分だけ確認”できるオプションを探す。|> >>PATH, HOME など、コマンドの振る舞いに影響する設定。ls, cd, cp, mv, rm, mkdir, rmdir, cat, less, head, tail, grep, find, wc, sort, uniq, cut, xargs, chmod, curl