Skip to main content
added 81 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 109
  • 163

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the jo(1) utility:

SCHEMA_DEFINITION=$(jo name=hello)

I would even suggest building the entire thing as a variable first:

schema_definition='{"name":"Hello"}'
modelClassName='"thisModel"'
json_string='{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName":'
json_string="$json_string $modelClassName"
json_string="$json_string"' "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": '"$schema_definition"

Which results in:

$ echo "$json_string"
{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName": "thisModel" "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": {"name":"Hello"}

So you can now just do:

aws glue create-schema --cli-input-json "$json_string"

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

I would even suggest building the entire thing as a variable first:

schema_definition='{"name":"Hello"}'
modelClassName='"thisModel"'
json_string='{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName":'
json_string="$json_string $modelClassName"
json_string="$json_string"' "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": '"$schema_definition"

Which results in:

$ echo "$json_string"
{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName": "thisModel" "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": {"name":"Hello"}

So you can now just do:

aws glue create-schema --cli-input-json "$json_string"

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the jo(1) utility:

SCHEMA_DEFINITION=$(jo name=hello)

I would even suggest building the entire thing as a variable first:

schema_definition='{"name":"Hello"}'
modelClassName='"thisModel"'
json_string='{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName":'
json_string="$json_string $modelClassName"
json_string="$json_string"' "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": '"$schema_definition"

Which results in:

$ echo "$json_string"
{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName": "thisModel" "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": {"name":"Hello"}

So you can now just do:

aws glue create-schema --cli-input-json "$json_string"
added 621 characters in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

I would even suggest building the entire thing as a variable first:

schema_definition='{"name":"Hello"}'
modelClassName='"thisModel"'
json_string='{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName":'
json_string="$json_string $modelClassName"
json_string="$json_string"' "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": '"$schema_definition"

Which results in:

$ echo "$json_string"
{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName": "thisModel" "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": {"name":"Hello"}

So you can now just do:

aws glue create-schema --cli-input-json "$json_string"

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

I would even suggest building the entire thing as a variable first:

schema_definition='{"name":"Hello"}'
modelClassName='"thisModel"'
json_string='{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName":'
json_string="$json_string $modelClassName"
json_string="$json_string"' "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": '"$schema_definition"

Which results in:

$ echo "$json_string"
{"RegistryId": {"RegistryName": "hxp-schema-registry"},"SchemaName": "thisModel" "DataFormat": "AVRO","Compatibility": "FULL_ALL","SchemaDefinition": {"name":"Hello"}

So you can now just do:

aws glue create-schema --cli-input-json "$json_string"
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

The shell is eating your quotes. Quotes are special for the shell, it needs them to protect other special characters like spaces:

$ var=aaa bb cc
bash: bb: command not found
terdon@tpad ~ $ var="aaa bb cc"
terdon@tpad ~ $ echo "$var"
aaa bb cc

So, in your case, the shell thinks the quites are there to protect the value so it doesn't save them as part of the variable's value:

$ SCHEMA_DEFINITION={"name":"Hello"}
$ echo "$SCHEMA_DEFINITION"
{name:Hello}

But don't worry, there's an easy fix! You can use single quotes around the variable definition:

$ SCHEMA_DEFINITION='{"name":"Hello"}'
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can escape the quotes:

$ SCHEMA_DEFINITION={\"name\":\"Hello\"}
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}

Or you can use the printf builtin command:

$ printf -v SCHEMA_DEFINITION '{"%s":"%s"}' "name" "Hello"
$ echo "$SCHEMA_DEFINITION"
{"name":"Hello"}