1 min readOct 2, 2020
Hello again Mohamed!
Now I understand you better. To answer your question, We'll use this example:
echo fooosomethingbarrrrr | awk '{ match($0, /(fo+).+(bar*)/, arr)}END{print arr[1] arr[2]}'
And here's the result!
fooo barrrrr
Now As you can see, match take as arguments a given string, a regex, and an array in which it returns the different groups.
Please keep in mind that match with 3 arguments i s only available for gawk and not mawk.
Hope this answers your question!