FIND YOUR NEXT FEW LINES

Results for “shell”

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

150 snippets foundClear filters
PowerShellFiles & paths

Create a directory if needed

Ensure a directory exists before writing output.

New-Item✓ Tested
Linux CommandsFiles & permissions

Create private files with a restrictive umask

Linux Commands: Apply umask in a subshell so the surrounding shell is unaffected.

Linux Commands✓ Tested
PowerShellFunctions & control

Define a function with a typed parameter

Accept a name and return a greeting.

function✓ Tested
Bash ScriptsProcesses & environment

Export a value to child processes

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

Bash Scripts✓ Tested
PowerShellCollections & objects

Filter items in a pipeline

Keep numbers that meet a condition.

Where-Object✓ Tested
PowerShellText & data

Format a date without locale ambiguity

Parse an ISO date and format it consistently.

date✓ Tested
PowerShellFunctions & control

Handle a terminating error

Catch conversion failures and produce a clear fallback.

try catch✓ Tested
Docker / ComposeDockerfile patterns

Keep exec-form arguments literal

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

Docker / Compose✓ Tested
PowerShellFiles & paths

List files by extension

Enumerate regular files and return their names in order.

Get-ChildItem✓ Tested
Bash ScriptsFunction scope & composition

Load functions from a trusted local script

Bash Scripts: Source executes a file in the current shell so its function definitions remain available.

Bash Scripts✓ Tested
PowerShellText & data

Parse JSON into an object

Access a named field in a JSON document.

JSON✓ Tested
Linux CommandsDates & process utilities

Pass a variable to one command

Linux Commands: Use env to supply a child process value without setting it permanently in the parent shell.

Linux Commands✓ Tested