Results for “Strings & literal text”
Small, practical examples. Search by task or narrow things down below.
Capture standard output and standard error separately
Bash Scripts: Use distinct redirections when diagnostic text should not be mixed with data.
Bash Scripts✓ Tested
Check exact array membership
Bash Scripts: Compare each element literally instead of searching a concatenated string.
Bash Scripts✓ Tested
Check for a substring
Perform a case-sensitive JavaScript substring check.
JavaScript✓ Tested
Clean up a temporary directory automatically
Python: Use TemporaryDirectory as a context manager so cleanup also happens after exceptions.
Python✓ Tested
Compare a row with the previous row
Read a preceding value with LAG.
LAG✓ Tested
Continue an ordered list at a chosen number
HTML: The start attribute controls the initial ordinal without changing item text.
HTML✓ Tested
Convert a string to lowercase
Normalize a text value using Bash expansion.
lowercase✓ Tested
Convert bytes to Base64 and back
C#: Encode text to UTF-8 before converting it to a Base64 representation.
C#✓ Tested
Copy a file to a chosen destination
PowerShell: LiteralPath prevents wildcard characters in the source filename from being interpreted.
PowerShell✓ Tested
Count day boundaries between dates
Compare date values with DATEDIFF.
DATEDIFF✓ Tested
Count lines in a file
Count newline characters in a text file, printing only the count without the filename.
lines✓ Tested
Declare LF normalization for a file type
Git: A gitattributes rule records text normalization expectations for matching paths.
Git✓ Tested