Results for “first lines”
Small, practical examples. Search by task or narrow things down below.
Build an image with a default command
Docker / Compose: Build an image with a default command with a complete introductory Dockerfile.
Docker / Compose✓ Tested
Count newline characters
Count newline bytes in a C file while retaining EOF as an int.
C✓ Tested
Create a complete HTML document
HTML: Learn how to create a complete HTML document in a complete browser example.
HTML✓ Tested
Find a matching item with a fallback
C#: Use the FirstOrDefault overload with an explicit default value.
C#✓ Tested
Observe command substitution’s trailing-newline removal
Bash Scripts: Command substitution removes trailing newlines while preserving embedded ones.
Bash Scripts✓ Tested
Process a file as a lazy line sequence
C#: ReadLines avoids allocating one string containing the entire file.
C#✓ Tested
Process a text file one line at a time
Java: Use a buffered reader to avoid loading a large file into memory.
Java✓ Tested
Read a file lazily through the .NET line iterator
PowerShell: ReadLines avoids creating one string containing the entire file.
PowerShell✓ Tested
Read a file without losing its last line
Handle spaces, backslashes, and a final line without a newline.
read lines✓ Tested
Read one JSON document per line
Python: Parse nonempty JSON Lines records independently instead of loading a JSON array.
Python✓ Tested
Read text line by line
Read text line by line using a complete Go program with explicit sample inputs.
Go✓ Tested
Archive filenames safely with null delimiters
Linux Commands: Use find -print0 with tar --null to preserve spaces and embedded newlines in filenames.
Linux Commands✓ Tested