Blog

Guides and tutorials for real text workflows

Practical walkthroughs for line counting, file-based text analysis, spreadsheets, command line workflows, and browser-based cleanup tools.

10 min read

How to Count Lines in AWK (NR, FNR, and Why They're Different With Multiple Files)

Count lines in AWK with END{print NR}, per-file FNR patterns, RS record separator changes, and match counting. Covers NR vs FNR, GNU awk ENDFILE, nonblank-line counting, and when wc -l is the better tool.

13 min read

How to Count Lines in a File in C (And Why `fgetc` Is 9x Slower Than `fread`)

Count lines in a file in C — fgets, fread, mmap, and the large performance gap between them. Covers `wc -l` internals, Windows vs Linux portability, long-line traps, and production-ready counting patterns for large files.

12 min read

How to Count Lines in a File in C++ (And Two Classic Traps That Catch Everyone)

Count lines in a file in C++ using ifstream, istreambuf_iterator, fread, and mmap. Covers the while(!eof()) off-by-one trap, the single-pass istreambuf_iterator reset issue, and why newline-byte counters must fix the missing final newline case.

9 min read

How to Count Lines with grep (-c Flag, Total Lines, and the Multi-File Advantage)

Count lines with grep using -c for matches, grep -c '' for total lines, and grep -vc for non-matching lines. Covers multi-file per-file counts, GNU grep vs BSD grep compatibility, missing trailing newline behavior, and grep vs wc -l tradeoffs.

14 min read

How to Count Lines in a File in Haskell (And Why `lines ""` Is Not the Real Trap)

Count lines in a file in Haskell — readFile, lines, Data.ByteString, and strict vs lazy IO. Covers the `lines ""` myth, final-newline off-by-one bugs, Lazy IO file descriptor leaks, and high-performance streaming with ByteString.

14 min read

How to Count Lines in a File Using Kotlin (And the useLines Sequence Trap Nobody Documents)

Count lines in a file using Kotlin — File.readLines, useLines, BufferedReader, and Coroutines Flow. Covers the useLines Sequence escape trap, OOM risks, and Android/Spring Boot patterns with benchmarks.

11 min read

How to Count Lines in a File in Lua (And the io.lines Version Trap Nobody Warns You About)

Count lines in a file in Lua — io.lines, io.open, and byte scanning. Covers io.lines close behavior across Lua 5.1 to 5.4, LuaJIT and embedded runtime patterns, and high-performance counting for large files.

11 min read

How to Count Lines in a File with Node.js (readline, Streams, and the Modern for await...of Pattern)

Count lines in a file with Node.js using readFileSync, readline, fs.createReadStream, and manual Buffer scanning. Covers trailing newline edge cases, for await...of, callback versus Promise tradeoffs, and large-file streaming in Node.js 22+.

12 min read

How to Count Lines in a File in Perl (And the $. Variable Nobody Fully Explains)

Count lines in a file in Perl — using $., while loops, sysread, and wc -l. Covers the $. not-reset trap across multiple files, IO::File input_line_number, and high-performance byte scanning for bioinformatics and sysadmin use cases.

13 min read

How to Count Lines in a File Using PHP (Three Methods, Three Traps)

Count lines in a PHP file — file(), fgets loop, SplFileObject, and shell exec. Covers the feof off-by-one trap, OOM from file(), and the fastest method for large files with benchmarks.

11 min read

How to Count Lines in a File in PowerShell (And Why `-ReadCount` Matters)

Count lines in a file in PowerShell with Get-Content, Measure-Object -Line, -ReadCount tuning, -Raw, and .NET file APIs. Covers the Count-versus-Measure object-shape trap, large-file performance, and low-memory StreamReader patterns.

13 min read

How to Count Lines in a File in R (And Fix the "incomplete final line" Warning)

Count lines in a file in R — readLines(), readr::read_lines(), R.utils::countLines(), and system wc -l. Covers the "incomplete final line" warning, large-file memory traps, and practical Shiny, knitr, and bioinformatics patterns.

13 min read

How to Count Lines in a File Using Ruby (And the Encoding Trap Nobody Warns You About)

Count lines in a file using Ruby — File.foreach, readlines, IO.read, and wc -l. Covers the invalid byte sequence trap, memory issues, and Rails-safe patterns with benchmarks.

13 min read

How to Count Lines in a File in Scala (And the Source File Handle Leak Nobody Talks About)

Count lines in a file in Scala — Source.fromFile, scala.util.Using, and Java NIO. Covers the Source file handle leak, getLines lazy iterator trap, Spark large-file patterns, and Scala 2.13+ Using utility with benchmarks.

9 min read

How to Count Lines in sed (And Why $= Is Not the Same as $p)

Count lines in sed with sed -n '$=', understand the $= vs $p difference, handle multiple files, and avoid CRLF surprises. Covers GNU sed vs BSD sed, pattern-based counting, and when wc -l is the better tool.

14 min read

How to Count Lines in a File Using Swift (And the autoreleasepool Trap That Crashes Your App)

Count lines in a file using Swift — String(contentsOfFile), FileHandle, and async/await. Covers the autoreleasepool memory trap, iOS memory warnings, and SwiftUI progress patterns with benchmarks.

11 min read

How to Count Lines in a File in TypeScript (And the readFileSync Buffer Type Trap)

Count lines in a file in TypeScript with readFileSync, readline streams, and Buffer scanning. Covers the Buffer-versus-string type trap, readline behavior when the last line has no newline, and when callback-style Node.js APIs are still worth preferring.

9 min read

How to Count Lines in Vim (5 Methods, Including the One That Also Counts Words and Bytes)

Count lines in Vim with Ctrl+G, g Ctrl+G, :$, line('$'), and substitution counts. Covers the :%s/pattern//n count, the :%s/\n//gn trap, Visual selection counts, and Vimscript automation.

15 min read

How to Count Lines in a File Using C# (And the Int32 Overflow Trap Nobody Warns You About)

Count lines in a file using C# — File.ReadAllLines, File.ReadLines, StreamReader, and async methods. Includes the Int32 overflow trap, GC pressure benchmarks, and .NET 6+ best practices.

16 min read

How to Count Lines in a File Using Rust (The Right Way, and the Fast Way)

Count lines in a file using Rust — from .lines().count() to zero-allocation byte scanning. Covers the 8KB buffer trap, String allocation overhead, and concurrent multi-file processing with Rayon.

18 min read

How to Count Lines in a File on Linux, macOS, and Windows

Count lines in any file on Linux, macOS, or Windows using wc -l, PowerShell, CMD, and GUI tools. Includes large file methods, CSV row counting, and cross-platform scripts.

16 min read

How to Count Lines in Bash: The Complete Guide with Edge Cases

Master line counting in Bash: count lines in files, variables, command output, and directories. Covers wc -l pitfalls, empty files, filenames with spaces, and shell script usage.

14 min read

How to Count Lines in a File Using Go (And the bufio.Scanner Trap You Need to Know)

Count lines in a file using Go — bufio.Scanner, bytes.Count, and manual byte scanning. Includes the critical 64KB buffer limit fix, benchmark results, and concurrent file processing.

16 min read

How to Count Lines in a File Using Java (6 Methods, Benchmarked)

Count lines in a file using Java — BufferedReader, Files.lines, LineNumberReader, BufferedInputStream, and more. Includes benchmark results for 5GB files and Java 8–17 examples.

18 min read

How to Count Lines in JavaScript: 6 Methods with Performance Benchmarks

Count lines in JavaScript strings, files, Node.js streams, and the browser. Includes real performance benchmarks, edge case handling, and a decision guide for every scenario.

20 min read

How to Count Lines in Python: 7 Methods, Benchmarked and Battle-Tested

Count lines in Python strings, text files, large files, and directories. Includes real performance benchmarks, empty file handling, splitlines vs split, and production-ready functions.

15 min read

How to Count Rows in SQL: The Complete Guide (MySQL, PostgreSQL, SQLite, SQL Server)

Master SQL row counting: COUNT(*) vs COUNT(1) vs COUNT(col), fast row estimates without full scans, and cross-database syntax for MySQL, PostgreSQL, SQLite, and SQL Server.

14 min read

How to Count Lines in VS Code: Every Method Explained

Count lines in VS Code without plugins using the status bar, keyboard shortcuts, and terminal. Plus: count lines across an entire project, exclude comments, and compare extensions.

14 min read

How to Count Lines in Excel: Every Method Explained

Complete guide to counting rows and lines in Excel with ROWS, COUNTA, COUNTIF, COUNTIFS, SUBTOTAL, VBA, Power Query, and dynamic arrays.

Python and scripting

Automate repetitive text work

Use the blog when you need command line examples, small scripts, and repeatable workflows that go beyond the browser UI.

Files and spreadsheets

Move between exported data and clean text

Several guides focus on common file workflows, such as counting lines in local files or cleaning spreadsheet-style content before import.

Tool companion content

Understand when to use each tool

The articles complement the interactive tools by explaining the tradeoffs between line counts, file workflows, browser tools, and manual editor steps.

What You Will Find in This Blog

This blog is designed to answer the questions that appear right before or right after someone uses a text tool. That might mean showing how to count lines in a file with shell commands, how to handle spreadsheet exports without breaking row structure, or how to move from a browser-based workflow into Python or another scripting language when the task becomes repetitive.

The goal is to keep the articles practical. Each guide should help a visitor finish a specific task, not just define a term. If you want to jump from a guide into an interactive workflow, the tools directory is the fastest next step.