I use a bash script based on the technology used here: Get color output in bash to color the output of my collections and other scripts to make reading easier. One of the steps in my build is doing a βgit pullβ, and the git server spits out a βwelcomeβ line like this among many other outputs:
** WARNING: THIS IS A PRIVATE NETWORK. UNAUTHORIZED ACCESS IS PROHIBITED. ** Use of this system constitutes your consent to interception, monitoring, and recording for official purposes of information related to such use, including criminal investigations.
I want to color this particular message yellow or possibly remove it from the output, leaving the rest of the output separate. I tried replacing a simple line like this:
WelcomeMessage="WARNING" pathpat=".*" ccred=$(echo -e "\033[0;31m") ccyellow=$(echo -e "\033[0;33m") ccend=$(echo -e "\033[0m") git pull 2>&1 | sed -r -e "/$WelcomeMessage/ s%$pathpat%$ccyellow&$ccend%g"
The first line of the welcome line is colored yellow as expected, but the remaining lines are not. I would really like to color the exact welcome line and only this line, but for many reasons this does not work:
WelcomeMessage="** WARNING: THIS IS A PRIVATE NETWORK. UNAUTHORIZED ACCESS IS PROHIBITED. ** Use of this system constitutes your consent to interception, monitoring, and recording for official purposes of information related to such use, including criminal investigations." pathpat=".*" ccred=$(echo -e "\033[0;31m") ccyellow=$(echo -e "\033[0;33m") ccend=$(echo -e "\033[0m") git pull 2>&1 | sed -r -e "/$WelcomeMessage/ s%$pathpat%$ccyellow&$ccend%g"
This is not an error: sed: -e expression # 1, char 78: reterx unterminated address
I looked at a couple of other questions, and I managed to avoid the asterisks (preceding them with backslashes), but I am puzzled by periods and a few lines. I would like to continue using sed to solve this problem, as it goes well with the paint solution.
Any help is appreciated. Thanks!