Forum Discussion
Issue with a simple Bash Script for adding an iRule to a list of Virtual Servers.
It looks like your regex is a little too greedy and is matching the ending curly brace of the vs name.
One universal "how to make simple regexes" approach is to avoid using (.+) which tends to match too much stuff, and using this sort of thing instead: ([^ ]). The square brackets mean "characters in the set of" and caret means "not", so ([^ ]+) means "capture one or more characters that are not a space". This is a safe way to match a value where you know the delimiter beforehand: VSs won't have a space and will always be followed by a space.
So your regex becomes:
if [[ $full_vs_info =~ ltm\ virtual\ ([^\/]+)/([^ ]+) ]]; then
A few other things:
- You can pass an "-p" to get read to give the user a prompt which will make it a little easier to use
- TMSH has a "one-line" argument that tells it to list each config object in its own line to make the kind of text processing you're doing here easier, for example "tmsh list /ltm virtual recursive one-line"
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com