1

I am working on my fish.config for using the fish shell.

I am trying to compare strings using bash syntax but fish doesn't accept the syntax. There is clearly another way to do it. Any suggestions for a solution as clean as the bash solution below?

if [[ $STRING == *"other_string"* ]]; then
    echo "It contains the string!"
fi
4

It looks to me like there's a string function for that purpose:

$ set STRING something here
$ string match -q "other_string" $STRING; and echo yes
$ set STRING some other_string here
$ string match -q "other_string" $STRING; and echo yes
yes

Or:

if string match -q "other_string" $STRING
  echo it matches
else
  echo is does not match
end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.