0

I am trying to use the following ansible-vault command in a bash script and store its output into an array:

ansible-vault encrypt_string --vault-password-file ./password "string" --name 'encrypted_val' | values[i++] 

If I have the following command on its own, it prints the encrypted value:

encrypted_val: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          63626631313232396664393364363435363939323966623163343463326630613632626336363361
          3837356365373434353331386563656162316338613036360a393362646661633136326537646230
          65386331613833336565653062616237653831333763616332346364633536306539303839313061
          3230633261396138650a343465316332666636373436366136313337303238613365363365343931
          3662
Encryption successful

I want to store this output in an array. Thanks in advance!

M. Naveed
  • 13
  • 6
  • See also https://stackoverflow.com/questions/11426529/reading-output-of-a-command-into-an-array-in-bash or https://stackoverflow.com/questions/9449417/how-do-i-assign-the-output-of-a-command-into-an-array – miken32 Mar 19 '20 at 22:31
  • 1
    Thank you!! @miken32 – M. Naveed Mar 19 '20 at 22:34

0 Answers0