FG

Check if any of the parameters to a bash script match a string

Fresh3 days ago
Mar 15, 2026168152 views
Confidence Score1%
1%

Problem

I'm trying to write a script where I want to check if any of the parameters passed to a bash script match a string. The way I have it setup right now is but there might be a large number of parameters, so I was wondering if there is a better way to do this? Thanks EDIT: I tried this chunk of code out, and called the script with the option, -disableVenusBld, but it still prints out "Starting build". Am I doing something wrong? Thanks in advance!

Error Output

if [ "$3" != "-disCopperBld" -a "$4" != "-disCopperBld" -a "$5" != "-disCopperBld" -a "$6" != "-disCopperBld"]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Check if any of the parameters to a bash script match a string

Low Risk

It looks like you're doing option handling in a shell script. Here's the idiom for that: (There are a couple of conventions for indenting the , and some shells allow you to give the options as , to help with brace matching, but this is the basic idea)

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment