I would like to find a specific portion of a string using a regular expression in bash. Additionally, I would like to store that portion in another bash variable. By searching in the web, I could find one solution:
#!/bin/bash
string="aaa.ddd.config.uuu"
result=`expr match "$string" '\(.*\)\.config.*'`
echo $result
In the above case, I would like to find out the portion before "\.config" and want to store in another variable named result.
Is the above one a good and efficient approach?
I would like to know what would be a recommended way in such cases.