Fish string-match
  •  1 min read

string match PATTERN STRING

string match tests each STRING against PATTERN and prints matching substrings.

Multiple strings can be matched at once

string match -r 'one|two|three' one three four

# one
# three

The input strings can be a file glob

string match 'file?.ex' *


# file1.ex
# file2.ex
# file3.ex

Match patterns can be inverted with -v

string match -v 'file?.ex' *

# another_file.ex

Can be composed

# Invoke: 'go run *.go' while excluding test files. Useful when
# there are multiple files in the main package.
function gorun
  go run (string match -v '*_test.go' -- ./* | string match '*.go')
end