Sample Header Ad - 728x90

Regex to extract DKIM record from file

0 votes
2 answers
390 views
I'm trying to script the deployment of a postfix server, and creating DNS records accordingly. SPF ; DMARC and DKIM. The first two are pretty simple, but i'm struggling to extract the record from the file opendkim generated. This is the file that opendkim gives me :
mail._domainkey	IN	TXT	( "v=DKIM1; h=sha256; k=rsa; t=y; "
	  "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK9yGy7orNIceonobdyTxr0USLo9XlWoo2/hg5MU5Ix+7bKFN0exJIUEeNLDAOYXWZe/0vQZan3+vnry9v3pVxqwpNp/92/xbp0pILJBzc1i5YXFe60XAlBBWq+Y9UAY2uXXsiFY4IUmhGZdMCubuHguWy/R2HDmCwrtN5vn0XfQIDAQAB" )  ; ----- DKIM key mail for localhost
I would like an output suitable for dns records like
"v=DKIM1; h=sha256; k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK9yGy7orNIceonobdyTxr0USLo9XlWoo2/hg5MU5Ix+7bKFN0exJIUEeNLDAOYXWZe/0vQZan3+vnry9v3pVxqwpNp/92/xbp0pILJBzc1i5YXFe60XAlBBWq+Y9UAY2uXXsiFY4IUmhGZdMCubuHguWy/R2HDmCwrtN5vn0XfQIDAQAB"
I've tried several things, but i can't even extract what's between parenthesis with the commands i've found here : https://unix.stackexchange.com/questions/103004/grep-regex-only-for-match-anything-between-parenthesis It looks like there's some line return problems or i don't know Thanks for reading, sorry for bad english ! Have a nice day
Asked by KayZnn (1 rep)
Feb 8, 2023, 04:29 PM
Last activity: Feb 11, 2023, 11:38 AM