In my specific situation, I need to scroll through several hundred files containing the variable in which the URL is stored. All URLs are different, but for this example we can assume that they all end in "com"
I need to add text right after com
Since all URLs will have different domains, I cannot use the sed command, for example:
sed -i 's/^ENVIRONMENT="someurl.com"/ENVIRONMENT="someurl.com.origin.net"/g'
Since the files contain other lines that com may contain, I cannot use something like:
sed -i 's/com/com.origin.net/g'
I need to do this search and replace only with a specific line containing the template, for example, from my example below in regex:
^ENVIRONMENT.*
sed , , sed, sed -i 's/com/com.origin.net/g'. , , bash script, , liner, sed, , , , .
Google , , :
https://unix.stackexchange.com/questions/37518/how-to-sed-only-that-lines-that-contains-given-string
. , sed , , sed.
, , .
### Example File
#
#
# someurl.com
ENVIRONMENT="someurl.com"
"ENVIRONMENT =" someurl.com "" "ENVIRONMENT =" someurl.com.orign.net "
, , sed, , script, :
` f *.config; do File2BeEdited = $(cat $f | grep ^ PatternToIdentifyLine | grep -v LinesThatAreAlreadyCorrect); if [ "$ File2BeEdited"!= "], RunSedCommand; printf" \n , .\n sed $f → log.log";