I have a bash script that needs the count of records/documents that exist for a given arango collection. This seemed easy enough, I used the following arangosh
call:
records=$(docker exec -it arango arangosh --javascript.execute scripts/getCount.js $collection --server.password '')
which then runs the following script:
#!/usr/bin/arangosh --javascript.execute
var collection = ARGUMENTS[0];
var doc = db[collection];
var c = doc.count();
print(c);
This appears to work, but when I echo $records
I get the correct value but it appears bolded. This leads to other reading issues so I redirected the docker exec
call to cat -v
and got the following output:
^[[1m#####^[[0m^M
The #### is my record value and it is correct. How do I either properly print the value out of arangosh
or out of docker exec
? Or is the only path to strip these hidden ansi characters from my value?
UPDATE:
I was able to attempt docker exec -it arango arangosh
and attempt the command db._collection('my_collection').count()
directly. This returned a bolded value which I believe means that it contains the hidden characters (arangosh
doesn't have cat
defined so I couldn't verify 100%).
With that said I believe the question is, can this be exported in plain text or do I need to sed
substitute these characters after my script receives the response?