I’m using a shell script and mdfind to locate files that contain a certain tag. It fails when the file tag contains an apostrophe. I’ve tried escaping the apostrophe, but it doesn’t help. Here’s an example of a search
To expand on @AlbertoD 's answer, anything between the apostrophes is literal so you have to exit the string with an apostrophe, add an escaped apostrophe, then resume the string.
echo 'string'\''s for "you"'
> string's for "you"
Or you could flip it and use double-quotes around the whole string and escape any double-quotes within the string: