FIND YOUR NEXT FEW LINES

Results for “pattern”

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

63 snippets foundClear filters
Linux CommandsSearching text

Branch on whether a pattern exists

Linux Commands: Use grep -q in a conditional so an ordinary no-match result is not an unhandled failure.

Linux Commands✓ 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
PowerShellFunctions & parameter validation

Dispatch values with wildcard patterns

PowerShell: Switch -Wildcard interprets shell-style matching patterns for each clause.

PowerShell✓ Tested
Bash ScriptsFiles & reliability

Handle a filename pattern with no matches

Use nullglob so an unmatched pattern produces an empty array.

nullglob✓ Tested
GitTags & repository configuration

List release tags matching a pattern

Git: Use a tag pattern and version-aware sorting for release labels.

Git✓ Tested
Linux CommandsSearching text

Match any pattern from a file

Linux Commands: Use grep -F -f with one literal pattern per line.

Linux Commands✓ Tested
C#Types & reliable control flow

Narrow an object using a type pattern

C#: A successful is pattern introduces a strongly typed local variable.

C#✓ Tested
JavaRecords & reliable control flow

Narrow an object with a pattern variable

Java: Pattern matching avoids a separate cast after a successful instanceof check.

Java✓ Tested
JavaDates & time zones

Parse a date with an explicit input pattern

Java: Use DateTimeFormatter for a non-ISO date representation.

Java✓ Tested
Arduino / CDigital signals & interrupts

Play a fixed digital output pattern

Arduino / C: A pattern table separates the output sequence from its timing.

Arduino / C✓ Tested
Bash ScriptsDiagnostics & defensive scripting

Prevent a variable value from expanding as a filename pattern

Bash Scripts: Quote a variable to pass its literal contents even when matching filenames exist.

Bash Scripts✓ Tested
Bash ScriptsParameter expansion

Remove a known prefix with a shell pattern

Bash Scripts: The hash expansion removes the shortest matching prefix without changing the original variable.

Bash Scripts✓ Tested