FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
Linux CommandsDates & process utilities

Add calendar days with GNU date

Linux Commands: Anchor date arithmetic at a fixed UTC date to avoid local daylight-saving ambiguity.

Linux Commands✓ Tested
Linux CommandsGetting Started

Append a line to a practice file

Linux Commands: Append a line to a practice file using GNU/Linux commands in an empty practice directory.

Linux Commands✓ Tested
Linux CommandsArchive integrity & packaging

Append a new member to an uncompressed tar

Linux Commands: Use tar -r for an existing uncompressed archive; compressed tar files cannot be appended this way.

Linux Commands✓ Tested
Linux CommandsStreams & byte tools

Append a stream to a log file

Linux Commands: Use tee -a to preserve existing log contents.

Linux Commands✓ Tested
Linux CommandsArchive integrity & packaging

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
Linux CommandsDates & process utilities

Bound a command execution time

Linux Commands: Use timeout and handle status 124 as an expected time limit.

Linux Commands✓ Tested
Linux CommandsGetting Started

Branch on a command’s exit status

Linux Commands: Branch on a command’s exit status using GNU/Linux commands in an empty practice directory.

Linux Commands✓ Tested
Linux CommandsSearching text

Branch on whether a pattern exists

Linux Commands: Use grep -q in a conditional so an ordinary no-match result is not an unhandled failure.

Linux Commands✓ Tested
Linux CommandsArchives & checksums

Calculate a SHA-256 checksum

Calculate a file checksum so you can compare it with a hash from a trusted source and detect changed contents.

checksum✓ Tested
Linux CommandsSystem information

Check available disk space

Show total, used, and available filesystem space for the current directory in human-readable units.

disk✓ Tested
Linux CommandsSystem information

Check memory usage

Show memory and swap totals in human-readable units. The available column estimates memory usable by new applications.

memory✓ Tested
Linux CommandsArchive integrity & packaging

Check the integrity of a gzip stream

Linux Commands: Use gzip -t to verify a compressed file without extracting it.

Linux Commands✓ Tested