A Shell script is preferred over a Perl script for this request.
From time to time I need to block a spam, so instead of going to the directory
& edit a file & save it, I would like to automate this a bit with a Shell script.
This script's requirements:
a) cd /folderA
b) make a backup of current file ie
cp -p access_sender access_sender.ddmmyyyy
where ddmmyyyy is the day, month, year (in digits)
c) prompt for the offending/spam email address I wish to block & store into a variable ie
Pls enter spam address to block: <this is where I'll key in the email address, eg: firstname.lastname@example.org>
d) use awk or nawk or sed to insert the email address entered into
line 3 of access_sender plus a TAB followed by the text REJECT. Eg:
Note: Lines 1 & 2 will stay while the former line 3, 4 onwards will get pushed down 1 line
e) then execute the command "postfix reload"