Forum Discussion
rbgnow_110245
Nimbostratus
Jan 16, 2009Get multiple fields from string
How to get multiple fields from a string variable.
Example:
echo "a.b.c.d.e.f"|cut -d. -f2,4-6
b.d.e.f
trying to find the similar feature using getfield like method.
- hoolio
Cirrostratus
You could use getfield for each field, but I think scan would be more efficient. Here are a few examples:when RULE_INIT { set ip 11.22.33.44 scan $ip {%d.%d.%d.%d} a b c d log local0. "$a, $b, $c, $d" set str "e f g h" scan $str {%s %s %s %s} a b c d log local0. "$a, $b, $c, $d" set str "i 2 k 4" scan $str {%s %s %s %s} a b c d log local0. "$a, $b, $c, $d" }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects