Quiz: Modern CLI Tools¶
5 questions
L0 (1 questions)¶
1. What modern CLI tool replaces grep -r for recursive code search, and what is its key speed advantage?
Show answer
ripgrep (rg). It is multi-threaded, respects .gitignore by default, and is significantly faster than grep -r on large codebases.L1 (2 questions)¶
1. How does zoxide decide which directory to jump to when you type 'z grok'?
Show answer
zoxide uses frecency — a combination of frequency and recency. It tracks which directories you visit and how recently you visited them, then jumps to the best match. More frequent and more recent visits rank higher.2. How does xargs handle filenames with spaces and special characters safely?
Show answer
Use null delimiters: find . -name '*.log' -print0 | xargs -0 rm. The -print0/xargs -0 pair uses \0 as separator instead of whitespace. For parallel execution: xargs -0 -P 4 -n 1 command runs 4 processes at once. Without -0, filenames containing spaces, quotes, or newlines break silently.L2 (2 questions)¶
1. Describe a pipeline combining rg, fzf, and bat to interactively browse files containing a pattern with a syntax-highlighted preview.
Show answer
rg --files | fzf --preview 'bat --color=always {}' — this lists all files via ripgrep, pipes them into fzf for interactive fuzzy selection, and uses bat to show a syntax-highlighted preview of the selected file in the fzf preview pane.2. How do you use awk to process fields with a custom delimiter and perform calculations?
Show answer
awk -F: '{sum += $3} END {print sum/NR}' /etc/passwd averages all UIDs. -F sets the field separator (default: whitespace). $1..$NF are fields; NR is record number; NF is field count. For multiple delimiters: -F'[,;:]'. For output formatting: awk -F, '{printf "%-20s %10.2f", $1, $3}' data.csv.