Just want to share with you something I did not easily find by myself...
I am a newbie in shell script and was just wondering how can I increment a value of a an associative array.
Let's assume this script:
#!/bin/bash
declare -A b # declare an associative array
a="aaa"
b[$a]=1
echo ${b[@]} # display all the values
echo ${b[$a]} # display the first value (1)
echo ${b[aaa]} # display the first value as well (1)
The solution can be
((b[$a]++))
echo ${b[@]} # display 2
Now that I found it, it seems evident, but I spent some time to get it...
I hope this can save some time to people :)
(('b[$a]'++)).a=' ',a=@,a=*,gniourf=hello; a='$gniourf'or even better:a='hi$(ls>&2)'(and you're glad I only put a friendly command there). Surprise.