Filter

filter_first

Return the first line of stdin.

Exit codes

  • 0: Always

Output on stdout

  • First line of input

filter_not_first

Return all lines of stdin except the first.

Exit codes

  • 0: Always

Output on stdout

  • All input lines after the first

filter_last

Return the last line of stdin.

Exit codes

  • 0: Always

Output on stdout

  • Last line of input

filter_not_last

Return all lines of stdin except the last.

Exit codes

  • 0: Always

Output on stdout

  • All input lines except the last

filter_matching

Return only lines from stdin matching a given pattern.

Arguments

  • $1 (string): The pattern to match against

Exit codes

  • 0: Always

Output on stdout

  • Lines matching the pattern

filter_not_matching

Return only lines from stdin that do not match a given pattern.

Arguments

  • $1 (string): The pattern to exclude

Exit codes

  • 0: Always

Output on stdout

  • Lines not matching the pattern

match_at_most_one

Pass stdin through only if it contains at most one line; fail if more.

Exit codes

  • 0: Zero or one line present
  • 1: More than one line present

Output on stdout

  • The single input line, or nothing if more than one line was present

match_at_least_one

Pass stdin through only if it contains at least one non-empty line.

Exit codes

  • 0: At least one line present
  • 1: No lines present

Output on stdout

  • Input passed through unchanged

match_exactly_one

Pass stdin through only if it contains exactly one non-empty line.

Exit codes

  • 0: Exactly one line present
  • 1: Zero or more than one line present

Output on stdout

  • The single input line

strip_trailing_newline

Strip the trailing newline from stdin output.

Exit codes

  • 0: Always

Output on stdout

  • Input with no trailing newline