FIND YOUR NEXT FEW LINES

Results for “working tree”

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

174 snippets foundClear filters
Bash ScriptsLoops & decisions

Dispatch a command with case

Choose an action from a small set of supported commands.

case✓ Tested
Bash ScriptsDiagnostics & defensive scripting

Distinguish an empty input line from end of input

Bash Scripts: A successful read can return an empty value; its status indicates whether a line was read.

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Distinguish unset variables from empty strings

Bash Scripts: Omitting the colon tests only whether a variable is unset; including it also treats an empty value as missing.

Bash Scripts✓ Tested
Bash ScriptsProcesses & environment

Export a value to child processes

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

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Extract a basename without an external process

Bash Scripts: Double hash removes the longest matching prefix ending in a slash.

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Extract a parent path with parameter expansion

Bash Scripts: Percent removes the shortest matching slash-and-suffix portion.

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Extract a substring by offset and length

Bash Scripts: Bash substring offsets start at zero for an ordinary string.

Bash Scripts✓ Tested
Linux CommandsFiles & folders

Find files by extension

Search a directory tree for regular files with a particular extension and print their paths.

find✓ Tested
Bash ScriptsText parsing & arithmetic

Format a numeric label with leading zeroes

Bash Scripts: Use a constant printf format string and supply values as separate arguments.

Bash Scripts✓ Tested
Bash ScriptsArguments & decisions

Forward all arguments without changing their boundaries

Bash Scripts: Quoted at-sign preserves empty arguments and embedded spaces.

Bash Scripts✓ Tested
Bash ScriptsFunctions & arguments

Give a function an optional argument

Let callers omit a value while keeping nounset enabled.

optional argument✓ Tested
Bash ScriptsFunction scope & composition

Give a function its own positional parameters

Bash Scripts: A function receives its call arguments without replacing the caller’s positional parameters.

Bash Scripts✓ Tested