Results for “shell”
Small, practical examples. Search by task or narrow things down below.
Create a directory if needed
Ensure a directory exists before writing output.
New-Item✓ Tested
Create private files with a restrictive umask
Linux Commands: Apply umask in a subshell so the surrounding shell is unaffected.
Linux Commands✓ Tested
Define a function with a typed parameter
Accept a name and return a greeting.
function✓ Tested
Export a value to child processes
Bash Scripts: Only exported shell variables are inherited through the environment.
Bash Scripts✓ Tested
Filter items in a pipeline
Keep numbers that meet a condition.
Where-Object✓ Tested
Format a date without locale ambiguity
Parse an ISO date and format it consistently.
date✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested
Keep exec-form arguments literal
Docker / Compose: JSON exec form does not expand shell environment variables.
Docker / Compose✓ Tested
List files by extension
Enumerate regular files and return their names in order.
Get-ChildItem✓ Tested
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
Parse JSON into an object
Access a named field in a JSON document.
JSON✓ Tested
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