Adding test to beginning and end of list in a file

Hi all and apologies for the silly question, but I've searched and I can't get this right.

I have a list of email addresses in a file that I need to blacklist (spam). the list is quite long and I would need to script a small routine so that I can get the following for each line in the file:

db spamassassin setprop wbl.global bademail@mail.com Black

So basically the bademail@mail.com is the variable and the rest needs to be added to each line in the file...

Thank you in advance and best to all
gio

Hello bm555,

Welcome to forums, hope you will enjoy learning/sharing knowledge here :b:. Request you to please show us the sample input(you could leave the sensitive data but show us near to it a test data) with expected output so that we could help you in same. Also please don't forget to user code tags for commands/codes/Inputs used in your code as per forum rules.

Thanks,
R. Singh

Hi and thanks for the reply..the input file is like this:

*@netzero.com
*@tijuana.mxwh.net
*@livegamesworld.com
*@iemailbox.com
steve2v@hotmail.com
helenaljufri@yahoo.com.au
aengelberg@nglbrg.com
msteeinfo@excite.com
DelayedReturn@ato.gov.au
oreartonishaybl@outlook.com

to each line I'd like to append db spam assassin setprop wbl.global at the beginning and Black at the end of each line, so that the result is:

db spamassassin setprop wbl.global oreartonishaybl@outlook.com Black

thanks again

Hello bm555,

Thank you for showing the sample input, please put coda tags for sample Inputs(email ids in this case). Following may help you in same.

awk '{print "db spamassassin setprop wbl.global oreartonishaybl " $0 " Black"}'  Input_file

Output will be as follows.

db spamassassin setprop wbl.global oreartonishaybl *@netzero.com Black
db spamassassin setprop wbl.global oreartonishaybl *@tijuana.mxwh.net Black
db spamassassin setprop wbl.global oreartonishaybl *@livegamesworld.com Black
db spamassassin setprop wbl.global oreartonishaybl *@iemailbox.com Black
db spamassassin setprop wbl.global oreartonishaybl steve2v@hotmail.com Black
db spamassassin setprop wbl.global oreartonishaybl helenaljufri@yahoo.com.au Black
db spamassassin setprop wbl.global oreartonishaybl aengelberg@nglbrg.com Black
db spamassassin setprop wbl.global oreartonishaybl msteeinfo@excite.com Black
db spamassassin setprop wbl.global oreartonishaybl DelayedReturn@ato.gov.au Black
db spamassassin setprop wbl.global oreartonishaybl oreartonishaybl@outlook.com Black

Also on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk .

Thanks,
R. Singh

1 Like

Thank you! it worked just fine...appreciate the help indeed!!