KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? 'foo' ]; then echo "It's there!" fi Where ?? is my unknown operator. Do I use echo and grep ? if echo "$string" | grep 'foo'; then echo "It's there!" fi That looks a bit clumsy.
Tags (comma-separated)
Save Edits
Cancel