Minion
Minion

Reputation: 125

how to give a variable path in bash shell?

I am writing a shell script where path can be ~/as-NY/com or ~/as-LN/com whatever is available. I can achieve this in K-shell as

cd ~/as-(NY|LN)/com, but not sure about bash. Can someone help here

Upvotes: 2

Views: 43

Answers (1)

anubhava
anubhava

Reputation: 784868

In BASH you need to enable extglob and do it like this:

shopt -s extglob
cd ~/as-@(NY|LN)/com

Upvotes: 2

Related Questions