Skip to content

Modern Cli

← Back to all decks

34 cards — 🟢 11 easy | 🟡 7 medium | 🔴 7 hard

🟢 Easy (11)

1. What does fd replace and what is its key advantage?

Show answer fd replaces find. Key advantages: respects .gitignore by default, regex patterns, colorized output, simpler syntax. Example: fd -e yaml finds all YAML files vs find . -name '*.yaml' -type f

Remember: fd = modern find. Smart case, colorized, .gitignore-aware. Simpler syntax.

2. What does rg (ripgrep) replace and why is it faster?

Show answer rg replaces grep -r. Faster because: multi-threaded, respects .gitignore, uses optimized regex engine (Rust). Automatically skips binary files and .git directories.

Remember: rg = faster grep. .gitignore-aware, recursive default, highlights. Rust-powered.

3. What is fzf and what problem does it solve?

Show answer fzf is an interactive fuzzy finder. Turns any list into a searchable, selectable menu. Pipe anything into it: kubectl get pods | fzf, git branch | fzf, history | fzf. Transforms CLI workflows from recall-based to recognition-based.

Remember: fzf = fuzzy finder. Pipe anything: `history | fzf`. Ctrl+R = game-changer.

Example: `FZF_DEFAULT_COMMAND='fd --type f'` uses fd for file search.

4. What is jq and when do you reach for it?

Show answer jq is a command-line JSON processor. Use whenever you get JSON output: kubectl -o json, AWS CLI, Terraform state, API responses. Basic patterns: jq '.' (pretty-print), jq '.key' (extract), jq '.[] | .name' (iterate).

Remember: jq = JSON processor. Essential for APIs. `curl url | jq '.data[] | .name'`.

Example: `jq -r '.items[] | [.name, .status] | @tsv'` — JSON to TSV.

5. What is yq and how does it relate to jq?

Show answer yq is jq for YAML (and TOML). Same filter syntax, works on YAML files directly. Essential for editing Kubernetes manifests, Helm values, and CI configs. Example: yq '.spec.replicas' deployment.yaml

Remember: jq = JSON processor. Essential for APIs. `curl url | jq '.data[] | .name'`.

Example: `jq -r '.items[] | [.name, .status] | @tsv'` — JSON to TSV.

6. What does eza replace and what does it add over ls?

Show answer eza replaces ls. Adds: colorized output by file type, built-in tree view (eza --tree), git status per file (eza -la --git), and icon support. Useful: eza --sort modified for recently changed files.

Remember: exa/eza = modern ls. Colors, git status, tree. `exa -la --git`.

7. What does bat replace and what does it add over cat?

Show answer bat replaces cat. Adds: syntax highlighting, line numbers, git diff markers, and automatic paging. Use bat -l yaml to force language. Set as MANPAGER for colorized man pages: export MANPAGER='bat -l man -p'

Remember: bat = cat + syntax highlighting + line numbers + git. Drop-in replacement.

8. What is delta and how do you set it up with git?

Show answer delta is a syntax-highlighting diff viewer. Add to .gitconfig: [core] pager = delta. Provides side-by-side view (delta -s), line numbers, and language-aware highlighting for git diff, git log -p, and git show.

Remember: delta = better git diff. Highlighting, line numbers. `git config core.pager delta`.

9. What does zoxide replace and how does it learn?

Show answer zoxide replaces cd. It learns from your navigation — tracks directory frequency and recency (frecency). z exercises jumps to most-visited match. zi opens interactive selection with fzf. Setup: eval \$(zoxide init bash)\""

Remember: zoxide = smart cd. Learns habits. `z proj` → /home/user/projects.

10. What does dust replace and what does it add over du?

Show answer dust replaces du. Provides visual bar charts of disk usage, sorted by size, with automatic depth. dust -n 20 shows top 20 entries. dust -d 2 limits depth. No need to pipe through sort -rh | head like with du.

Remember: Modern CLI = Rust-powered: rg, fd, bat, exa, delta, zoxide. Faster, friendlier.

Example: Replace: grep→rg, find→fd, cat→bat, ls→exa, cd→zoxide, diff→delta.

11. When do you still use classic tools (grep, find, cat) over modern ones?

Show answer On remote servers without modern tools installed. In shell scripts that must be portable. In Dockerfiles (minimize image size). When piping to other programs that expect standard output format. Know both — modern for interactive work, classic for portability.

Remember: Modern CLI = Rust-powered: rg, fd, bat, exa, delta, zoxide. Faster, friendlier.

Example: Replace: grep→rg, find→fd, cat→bat, ls→exa, cd→zoxide, diff→delta.

🟡 Medium (7)

1. How do you find and execute a command on matching files with fd?

Show answer fd -e py -x wc -l (count lines in each Python file). fd -e log -X rm (delete all .log files — -X batches into one command, -x runs per file). Add -H to include hidden files.

Remember: fd = modern find. Smart case, colorized, .gitignore-aware. Simpler syntax.

2. How do you search only specific file types with rg?

Show answer rg 'pattern' -t yaml (built-in type filter). rg 'pattern' -g '*.yaml' (glob filter). rg -t py -g '!test*' 'pattern' (Python files excluding tests). rg --type-list shows all built-in types.

Remember: rg = faster grep. .gitignore-aware, recursive default, highlights. Rust-powered.

3. What are the three key fzf shell keybindings?

Show answer Ctrl-R: fuzzy search command history. Ctrl-T: fuzzy find and insert a file path. Alt-C: fuzzy cd into a subdirectory. Enable with: eval \$(fzf --bash)\" in .bashrc (or --zsh/--fish)."

Remember: fzf = fuzzy finder. Pipe anything: `history | fzf`. Ctrl+R = game-changer.

Example: `FZF_DEFAULT_COMMAND='fd --type f'` uses fd for file search.

4. How do you filter and reshape JSON with jq?

Show answer Filter: jq '.items[] | select(.status == \running\")'. Reshape: jq '{name: .metadata.name, phase: .status.phase}'. Raw output: jq -r '.name' (no quotes). Slurp: jq -s '.' (read all inputs into array)."

Remember: jq = JSON processor. Essential for APIs. `curl url | jq '.data[] | .name'`.

Example: `jq -r '.items[] | [.name, .status] | @tsv'` — JSON to TSV.

5. How do you modify a YAML file in-place with yq?

Show answer yq -i '.spec.replicas = 3' deployment.yaml. Add a field: yq -i '.metadata.labels.env = \prod\"' deployment.yaml. Delete: yq -i 'del(.spec.template.metadata.annotations)' deployment.yaml."

Remember: Modern CLI = Rust-powered: rg, fd, bat, exa, delta, zoxide. Faster, friendlier.

Example: Replace: grep→rg, find→fd, cat→bat, ls→exa, cd→zoxide, diff→delta.

6. How do you use bat as a previewer for other tools?

Show answer With fzf: fzf --preview 'bat --color=always {}'. With git: git diff | bat -l diff. As pager: export BAT_PAGER='less -RF'. bat -A shows whitespace characters (tabs, spaces, newlines).

Remember: bat = cat + syntax highlighting + line numbers + git. Drop-in replacement.

7. What is the modern-tool equivalent of 'find . -name *.yaml | xargs grep replicas | sort'?

Show answer rg 'replicas' -t yaml. One command replaces the entire pipeline. Add -C 2 for context, -l for file names only, --stats for totals. rg handles .gitignore, binary files, and multi-threading automatically.

Remember: rg = faster grep. .gitignore-aware, recursive default, highlights. Rust-powered.

🔴 Hard (7)

1. How do you use rg to find files containing a string and show context?

Show answer rg 'error_handler' -C 3 (3 lines before and after). rg -l 'error_handler' (file names only). rg -c 'error_handler' (count per file). --stats flag adds summary totals.

Remember: rg = faster grep. .gitignore-aware, recursive default, highlights. Rust-powered.

2. How do you combine fzf with file preview?

Show answer rg --files | fzf --preview 'bat --color=always {}' — browse files with syntax-highlighted preview. For git: git log --oneline | fzf --preview 'git show {1}' — preview commits interactively.

Remember: fzf = fuzzy finder. Pipe anything: `history | fzf`. Ctrl+R = game-changer.

Example: `FZF_DEFAULT_COMMAND='fd --type f'` uses fd for file search.

3. How do you count and aggregate with jq?

Show answer Count: jq '.items | length'. Group and count: jq '[.items[] | .status.phase] | group_by(.) | map({(.[0]): length}) | add'. TSV output: jq -r '[.timestamp, .service, .message] | @tsv'

Remember: jq = JSON processor. Essential for APIs. `curl url | jq '.data[] | .name'`.

Example: `jq -r '.items[] | [.name, .status] | @tsv'` — JSON to TSV.

4. When should you use z vs zi vs cd?

Show answer z for known frequent directories (z grok → /home/user/grokdevops). zi when multiple matches exist and you want to pick interactively. Plain cd for explicit paths or parent navigation (cd ..).

Remember: Modern CLI = Rust-powered: rg, fd, bat, exa, delta, zoxide. Faster, friendlier.

Example: Replace: grep→rg, find→fd, cat→bat, ls→exa, cd→zoxide, diff→delta.

5. How do you combine rg + fzf + bat for interactive code search?

Show answer rg 'pattern' -l | fzf --preview 'bat --color=always -H $(rg -n \pattern\" {} | head -1 | cut -d: -f1) {}' — lists matching files, preview highlights the match line. Powerful for exploring unfamiliar codebases."

Remember: rg = faster grep. .gitignore-aware, recursive default, highlights. Rust-powered.

6. How do you use jq to triage JSON logs from an application?

Show answer cat app.log | jq 'select(.level == \error\")' (filter errors). Count by service: jq -r 'select(.level == \"error\") | .service' | sort | uniq -c | sort -rn. Table output: jq -r '[.timestamp, .service, .message] | @tsv' | column -t"

Remember: jq = JSON processor. Essential for APIs. `curl url | jq '.data[] | .name'`.

Example: `jq -r '.items[] | [.name, .status] | @tsv'` — JSON to TSV.

7. You need to find all YAML files containing 'replicas' in a monorepo. Which tool chain do you pick?

Show answer rg 'replicas' -t yaml for the answer. If you need to browse the results interactively: rg 'replicas' -t yaml -l | fzf --preview 'bat --color=always {}'. Classic equivalent takes 3+ commands; rg does it in one.

Remember: Modern CLI = Rust-powered: rg, fd, bat, exa, delta, zoxide. Faster, friendlier.

Example: Replace: grep→rg, find→fd, cat→bat, ls→exa, cd→zoxide, diff→delta.