FIND YOUR NEXT FEW LINES

Results for “working”

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

162 snippets foundClear filters
Bash ScriptsLoops & decisions

Check whether input is a nonnegative integer

Reject empty input and nonnumeric characters before arithmetic.

validation✓ Tested
Bash ScriptsArguments & decisions

Choose among several numeric ranges

Bash Scripts: An if-elif chain evaluates branches in order and executes the first match.

Bash Scripts✓ Tested
Bash ScriptsGetting Started

Choose an action with case

Bash Scripts: Choose an action with case with a small standalone Bash program.

Bash Scripts✓ Tested
Bash ScriptsGetting Started

Choose between two script branches

Bash Scripts: Choose between two script branches with a small standalone Bash program.

Bash Scripts✓ Tested
Bash ScriptsText parsing & arithmetic

Clamp a numeric setting to a valid range

Bash Scripts: Use arithmetic comparisons before applying a user-supplied bounded setting.

Bash Scripts✓ Tested
Bash ScriptsArguments & decisions

Classify a filename with shell patterns

Bash Scripts: Case patterns support alternatives without launching an external regex tool.

Bash Scripts✓ Tested
Bash ScriptsFiles & reliability

Clean up a temporary directory automatically

Use an EXIT trap so temporary files are removed when the script ends.

mktemp✓ Tested
Bash ScriptsProcesses & environment

Collect two independent background results

Bash Scripts: Write each job’s output separately and wait for both before combining results.

Bash Scripts✓ Tested
Bash ScriptsArguments & decisions

Compare a value literally inside a conditional

Bash Scripts: Quoting the right side of an equality test makes wildcard characters literal.

Bash Scripts✓ Tested
Bash ScriptsInput streams & redirection

Compare two generated sorted streams

Bash Scripts: Process substitution lets a command consume another command’s output as a file-like input.

Bash Scripts✓ Tested
Bash ScriptsGetting Started

Compare two text values

Bash Scripts: Compare two text values with a small standalone Bash program.

Bash Scripts✓ Tested
Bash ScriptsArguments & decisions

Consume positional arguments one at a time

Bash Scripts: Check the argument count before accessing the first parameter with nounset enabled.

Bash Scripts✓ Tested