Using tmsh to manage data-groups

I’m trying to use tmsh to update an internal data-group on v11.1.0. I can create the data-group and add records to it, but when I try to create either a key or value that includes spaces I get an error.

In this example I create the data-group and add a key and value pair that don’t include spaces. This works as desired.

[root@mike-f5:Active] config tmsh create ltm data-group internal new_dg type string

[root@mike-f5:Active] config tmsh modify ltm data-group internal new_dg records add {“string1” {data “value”}}

[root@mike-f5:Active] config tmsh list ltm data-group internal new_dg

ltm data-group internal new_dg {

records {

string1 {

data value

}

}

type string

}

[root@mike-f5:Active] config

Now if I try to add a record that has a space in the key name I get an error:

[root@mike-f5:Active] config tmsh modify ltm data-group internal new_dg records add {“string2 with space” {data “value”}}

Syntax Error: records: required brace is missing “{”

[root@mike-f5:Active] config

I also get an error if I try to add a record that has a space in the value:

[root@mike-f5:Active] config tmsh modify ltm data-group internal new_dg records add {“string3” {data “value with space”}}

Syntax Error: incomplete command

[root@mike-f5:Active] config

I tried a few different combinations of quotes and escape characters but can’t seem to find anything that works…

I figured this out, turns out you just need to escape the quote with backslash. Here’s an example:

tmsh modify ltm data-group internal new_dg records add {\“string with space\” {data \“value with space\”}}