#text Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Bash Count Occurrences of a Pattern
Several ways to count matches: lines containing X, total matches across a file, matches grouped by capture, etc.
Bash Filter Lines by Regex
grep -E (extended regex) is the right tool 95% of the time. Combine -i (case-insensitive), -v (invert), -n (line numbers), -B/-A (context lines).
Bash Sort by a Specific Column
Sort takes -k for column-based ordering and -t to set the delimiter. -h sorts human-readable sizes ("1.5G", "300K") correctly.
Bash Sum a Column with awk
Awk's default field splitter is whitespace; pass a single character with -F. Perfect for summing the Nth column of a log file or CSV.
Bash Unique While Preserving Order
`sort -u` re-orders. `awk '!seen[$0]++'` is the classic order-preserving dedupe — and it's a single line.
Bash Find + Replace Across Many Files
Use `find` + `sed -i` to do project-wide refactors. Always test the regex first with a dry run.
JavaScript Calculate Reading Time
Estimates the reading time of a block of text based on an average adult reading speed (default 200 words per minute). Strips HTML tags before counting to handle rich-text content. Returns the result in minutes, rounded up, so a short article always shows at least "1 min read".
Bash Extract JSON Field with jq
jq is the de-facto JSON tool. Pipe any JSON in, get a parsed/filtered/reshaped result out. Indispensable in deploy scripts that consume API output.
Bash Word Frequency Count
Classic shell one-liner: split text into words, sort, count uniques, sort by count. Useful for log analysis, content audits, and tag-cloud-style summaries.