FIND YOUR NEXT FEW LINES

Results for “working”

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

162 snippets foundClear filters
Bash ScriptsFiles & reliability

Replace a text file with an atomic rename

Prepare new content beside the target before renaming it into place.

atomic write✓ Tested
Bash ScriptsVariables & text

Replace every occurrence in a string

Substitute text directly with Bash parameter expansion.

replace✓ Tested
Bash ScriptsGetting Started

Replace text with parameter expansion

Bash Scripts: Replace text with parameter expansion with a small standalone Bash program.

Bash Scripts✓ Tested
Bash ScriptsFunction scope & composition

Return a value through a named output variable

Bash Scripts: A Bash nameref can update a caller-supplied variable without command substitution.

Bash Scripts✓ Tested
Bash ScriptsFunction scope & composition

Return an array through a nameref

Bash Scripts: Assign through a nameref to preserve array element boundaries.

Bash Scripts✓ Tested
Bash ScriptsFunctions & arguments

Return text from a shell function

Capture a function’s output with command substitution.

function✓ Tested
Bash ScriptsArray operations

Select a range of array elements

Bash Scripts: Quote a sliced at-sign expansion to keep each selected element separate.

Bash Scripts✓ Tested
Bash ScriptsProcesses & environment

Set an environment value for one child command

Bash Scripts: A command-prefix assignment is visible to that command without overwriting the shell’s current variable.

Bash Scripts✓ Tested
Bash ScriptsText parsing & arithmetic

Set and clear a bit in a shell integer

Bash Scripts: Use shifts and bitwise operators for a small flag field.

Bash Scripts✓ Tested
Linux CommandsFiles & folders

Show the current directory

Print the absolute path of your current working directory before running commands that depend on relative paths.

directory✓ Tested
Bash ScriptsArguments & decisions

Skip selected iterations in a loop

Bash Scripts: Continue starts the next iteration without running the remaining loop body.

Bash Scripts✓ Tested
Bash ScriptsVariables & text

Split a line into named fields

Read a simple delimiter-separated line into variables.

read✓ Tested