I have a template config file with PlaceHolders, and i want to find all those PlaceHolders and put inside an array.
The curent state:
I can find all the PlaceHolders in file only if there is no more than one PlaceHolder in a line.
For example, this is my template file:
upstream portal {        
   server {{UNICORN_SERVICE_NAME}}:{{UNICORN_SERVICE_PORT}};  
}
server {
  listen *:80 default_server;         
  server_name {{APP_HOST}};     
  server_tokens off;     
  root /dev/null;
  # Increase this if you want to upload large attachments
  # Or if you want to accept large git objects over http
  client_max_body_size {{NGINX_MAX_UPLOAD_SIZE}};
  location {{GITLAB_RELATIVE_URL_ROOT}}/ {
    root /var/lib/nginx/portal;
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below    
  }
  }
this is the code i use to find the PlaceHolders:
matches_bloc=$(awk 'match($0, /(\{\{)([^{]*)(\}\})/) {
                    print substr($0, RSTART, RLENGTH)                    
                }' ${currFile})
            # convert 'matches_bloc' into array
            matches=()
            echo "Matches:"
            while read -r line; do
                matches+=("$line")
                echo "  - ${line}"
            done <<< "$matches_bloc"
in this example the matches result will be:
Matches:
- {{UNICORN_SERVICE_NAME}}
- {{APP_HOST}}
- {{NGINX_MAX_UPLOAD_SIZE}}
- {{GITLAB_RELATIVE_URL_ROOT}}
You can notice that there are 5 PlaceHolders in the file and only 4 matches.
The missing match is: {{UNICORN_SERVICE_PORT}}, because there is already another match in the same line.
My question is:
How can i find all the matches in the file regardless of the line?
 
     
    