FIND YOUR NEXT FEW LINES

Results for “variable”

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

84 snippets foundClear filters
CDynamic memory & ownership

Clear an owning pointer after releasing its allocation

C: Assigning NULL helps prevent accidental reuse through the same variable.

C✓ Tested
Bash ScriptsVariables & text

Convert a string to lowercase

Normalize a text value using Bash expansion.

lowercase✓ Tested
Bash ScriptsProcesses & environment

Export a value to child processes

Bash Scripts: Only exported shell variables are inherited through the environment.

Bash Scripts✓ Tested
Linux CommandsDates & process utilities

Format a zero-padded numeric label

Linux Commands: Use printf formatting instead of concatenating a variable number of zeroes.

Linux Commands✓ Tested
Bash ScriptsFunctions & arguments

Give a function an optional argument

Let callers omit a value while keeping nounset enabled.

optional argument✓ Tested
PowerShellStrings & literal text

Insert values into a multiline template

PowerShell: A double-quoted here-string expands variable references.

PowerShell✓ Tested
Docker / ComposeDockerfile patterns

Keep exec-form arguments literal

Docker / Compose: JSON exec form does not expand shell environment variables.

Docker / Compose✓ Tested
CStructures & function interfaces

Keep function state between calls

C: A static local variable retains its stored value for the lifetime of the process.

C✓ Tested
PowerShellFunctions & parameter validation

Keep function-local assignments separate from caller state

PowerShell: Ordinary function assignments create local variables rather than replacing the caller’s variable.

PowerShell✓ Tested
C#Types & reliable control flow

Narrow an object using a type pattern

C#: A successful is pattern introduces a strongly typed local variable.

C#✓ Tested
Docker / ComposeBuild images

Provide a default environment value

Set a runtime default that can be overridden at startup.

Dockerfile✓ Tested
Bash ScriptsVariables & text

Remove a filename extension

Keep the path while removing its final extension.

filename✓ Tested