I wrote following command to scan DDB (please correct me if I'm wrong). I want to get all value in id
column, when sortKey column contains text prefix|
:
aws dynamodb scan \
--table-name ProductTable \
--projection-expression "id" \
--filter-expression 'contains(sortKey,:p)' \
--expression-attribute-values '{":p":{"S":"prefix|"}}'
As a result, it returned a vim-view-like list, but how could I copy or save all results?
Thanks
You can output the result of a CLI command to a file using the
>
or>>
operator in the following syntax:aws dynamodb scan \ --table-name ProductTable \ --projection-expression "id" \ --filter-expression 'contains(sortKey,:p)' \ --expression-attribute-values '{":p":{"S":"prefix|"}}' > output.txt
In this example
output.txt
is the name of the file you want to output the result to. Its important to note that when you use>
operator the output of the command will not be displayed in the terminal and will be written to the specified file.It’a also important to note that each time you direct output to a file, the contents of the file will be replaced with the output of the most recent command to output to that file. If you’d prefer to append to the end of the file, instead of replacing the file contents you can use the double output operator
>>
instead of>
.