Question: I just want to know how Queries and Connections in Excel Workbooks are connected as objects. I noticed that I can use ThisWorkbook.Connections("Name of my connection").Refresh but that is not the same as the name used in my Queries (as I have commented out in my code).

```
Sub EditAllWorkbookFormuals(Order As String)
For Each q In ThisWorkbook.Queries
 q.Formula = NewQuery(q.Formula, Order)
 'q.Refresh
 'ThisWorkbook.Connections(q.Name).Refresh
 ThisWorkbook.Connections(1).Refresh
Next
'ThisWorkbook.RefreshAll
End Sub

```

Answer: 
First Put a valid [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) and paste your script at <https://shellcheck.net> for validation/recommendation.

---

With the assumption that the line starts with `config` and ends with `FLOW` e.g.

```
config_text = STACK OVER FLOW

```

---

Now the script.

```
#!/usr/bin/env bash

values="config_text = STACK OVER FLOW"
regexp="config_text = ([[:upper:]]{1})[^ ]+ ([[:upper:]]{1})[^ ]+ ([[:upper:]]{1}).+$"

while IFS= read -r line; do
  [[ "$line" = "$values" && "$values" =~ $regexp ]] &&
  printf '%s %s %s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}"
done < test_file.txt

```

---

If there is Only one line or the target string/pattern is at the first line of the `test_file.txt`, the `while` loop is not needed.

```
#!/usr/bin/env bash

values="config_text = STACK OVER FLOW"
regexp="config_text = ([[:upper:]]{1})[^ ]+ ([[:upper:]]{1})[^ ]+ ([[:upper:]]{1}).+$"

IFS= read -r line < test_file.txt
[[ "$line" = "$values" && "$values" =~ $regexp ]] &&
printf '%s %s %s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}"

```

---

* Make sure you have and running/using `Bashv4+` since MacOS, defaults to `Bashv3`
* See [How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?](https://mywiki.wooledge.org/BashFAQ/001)
Another option rather than bash regex would be to utilize bash parameter expansion substring `${parameter:offset:length}` to extract the desired characters:

```
$ read -ra arr <text.file ; printf "%s%s%s\n" "${arr[2]:0:1}" "${arr[3]:0:1}" "${arr[4]:0:1}"
SOF

```