Skip to content

Grep

Index

grep::contains_exactly

Return true if input contains the exact fixed string. With 1 arg (stdin): $1 = string to search for. With 2 args (file): $1 = file path, $2 = string to search for. ex: printf '%s\n' 'foobar' | grep::contains_exactly 'ooba' ex: grep::contains_exactly '/path/to/file' 'ooba'

Arguments

  • $1 (file): path (when 2 args) or string to search for (when 1 arg)
  • $2 (string): to search for (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_exactly_ignore_case

Return true if input contains the exact fixed string (case-insensitive). With 1 arg (stdin): $1 = string to search for. With 2 args (file): $1 = file path, $2 = string to search for.

Arguments

  • $1 (file): path (when 2 args) or string to search for (when 1 arg)
  • $2 (string): to search for (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_regex

Return true if input contains a line matching the given regex. With 1 arg (stdin): $1 = regex pattern. With 2 args (file): $1 = file path, $2 = regex pattern.

Arguments

  • $1 (file): path (when 2 args) or regex pattern (when 1 arg)
  • $2 (regex): pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_regex_ignore_case

Return true if input contains a line matching the given regex (case-insensitive). With 1 arg (stdin): $1 = regex pattern. With 2 args (file): $1 = file path, $2 = regex pattern.

Arguments

  • $1 (file): path (when 2 args) or regex pattern (when 1 arg)
  • $2 (regex): pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_perl_regex

Return true if input contains a line matching the given Perl-compatible regex. With 1 arg (stdin): $1 = Perl-compatible regex pattern. With 2 args (file): $1 = file path, $2 = Perl-compatible regex pattern.

Arguments

  • $1 (file): path (when 2 args) or Perl-compatible regex pattern (when 1 arg)
  • $2 (Perl-compatible): regex pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_perl_regex_ignore_case

Return true if input contains a line matching the given Perl-compatible regex (case-insensitive). With 1 arg (stdin): $1 = Perl-compatible regex pattern. With 2 args (file): $1 = file path, $2 = Perl-compatible regex pattern.

Arguments

  • $1 (file): path (when 2 args) or Perl-compatible regex pattern (when 1 arg)
  • $2 (Perl-compatible): regex pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_word

Return true if input contains the exact fixed string as a whole word. With 1 arg (stdin): $1 = word to search for. With 2 args (file): $1 = file path, $2 = word to search for.

Arguments

  • $1 (file): path (when 2 args) or word to search for (when 1 arg)
  • $2 (word): to search for (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_word_ignore_case

Return true if input contains the exact fixed string as a whole word (case-insensitive). With 1 arg (stdin): $1 = word to search for. With 2 args (file): $1 = file path, $2 = word to search for.

Arguments

  • $1 (file): path (when 2 args) or word to search for (when 1 arg)
  • $2 (word): to search for (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_word_regex

Return true if input contains a whole-word regex match. With 1 arg (stdin): $1 = regex pattern (matched as whole word). With 2 args (file): $1 = file path, $2 = regex pattern (matched as whole word).

Arguments

  • $1 (file): path (when 2 args) or regex pattern (when 1 arg)
  • $2 (regex): pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false

grep::contains_word_regex_ignore_case

Return true if input contains a whole-word regex match (case-insensitive). With 1 arg (stdin): $1 = regex pattern (matched as whole word). With 2 args (file): $1 = file path, $2 = regex pattern (matched as whole word).

Arguments

  • $1 (file): path (when 2 args) or regex pattern (when 1 arg)
  • $2 (regex): pattern (when 2 args)

Exit codes

  • 0: if true
  • 1: if false