Home > Mobile >  Sed to match any aws arn regex
Sed to match any aws arn regex

Time:09-09

I am trying to find aws arn from logs and change its color

regex I tried

echo 'arn:aws:lambda:us-east-2:421142534505:function:list-users"' |  sed -e "s/arn:\S*[^\s\"]/$(tput bold setaf 1)&$(tput setaf 9)/gi"

result I got

enter image description here

I want arn:aws:lambda:us-east-2:421142534505:function:list-users to be colored (any whitespace or " should not be colored)

CodePudding user response:

Using sed

$ sed "s/arn:aws[^\" ]*/$(tput setaf 1)&$(tput sgr 0)/g" input_file
  • Related