3.6.3. Shell Quoting Rules

Warning

This API is deprecated.

Axonius API v2 is now available, we recommend you move to API v2.

New features will no longer be added to this API. Axonius will only provide bug fixes.

Read about API v2

TBD: Add to axonshell –help-detailed

Different shells (powershell, cmd, bash, zsh) have their own nested quoting rules.

This becomes important when supplying queries built from the Query Wizard in the GUI, as the queries contain double quotes (") and even single quotes (') sometimes.

You can avoid having to deal with nested quoting by supplying the name of a file containing the query via -qf / --query-file instead of supplying the query on the command line using -q / --query.

Example of –query-file using a file that contains a query string:

$ axonshell devices get --query-file qf.txt

Example of –query-file using STDIN (although this still introduces the problems with quoting in certain cases):

$ echo 'QUERY HERE' | axonshell devices get --query-file -

3.6.3.1. Bash, zsh

For bash and zsh, you just need to surround the query with single quotes ('), unless the query includes single quotes, then you need to escape them with a backslash \.

$ axonshell devices get --query '(adapters == "aws_adapter")'

3.6.3.2. Powershell

For powershell, it’s a little more fun. You will need to do one of the following:

  • Surround the –query value with single quotes and add a second double quote ("") next to every double quote (").

  • Surround the –query with single quotes and add a backslash (\") before every double quote (").

$ axonshell devices get --query '(adapters == ""aws_adapter"")'
$ axonshell devices get --query '(adapters == \"aws_adapter\")'

3.6.3.3. Windows Command Prompt

For the Windows Command prompt, it’s like powershell, yet different!

You will need to do one of the following:

  • Surround the –query value with double quotes and add a second double quote ("") next to every double quote (").

  • Surround the –query with double quotes and add a backslash (\") before every double quote (").

$ axonshell devices get --query "(adapters == ""aws_adapter"")"
$ axonshell devices get --query "(adapters == \"aws_adapter\")"