Article 4V7DM How to remove lines with while loop whch were previously added

How to remove lines with while loop whch were previously added

by
blason
from LinuxQuestions.org on (#4V7DM)
Hi Folks,

I am a little confused here with my script.

I am reading from file; running in while loop; creating the zone.
This is working fine.
However, since I keep adding new entries; due to while loop those are getting added again and again.

Here is what I mean -
Quote:
_EXPL_WHITELIST="/zone/expl_wl_bl/customWL.txt"

if [ -f ${_EXPL_WHITELIST} ]
then
if [ -s ${_EXPL_WHITELIST} ]
then
cat $_EXPL_WHITELIST | while read line;do echo -e $line'\t'CNAME'\t'rpz-passthru.;done >> $_FINAL_WHITELIST
fi
fi
rndc reload
in the first iteration, I get an output like

Quote:
productreviews.shopifycdn.com CNAME rpz-passthru.
large.edgecast.syn-cdn.com CNAME rpz-passthru.
www.anrdoezrs.net CNAME rpz-passthru.
scontent-frt3-1.xx.fbcdn.net CNAME rpz-passthru.
In the next iteration If I add "new.com" and "net.net" and re-run the script

Quote:
productreviews.shopifycdn.com CNAME rpz-passthru.
large.edgecast.syn-cdn.com CNAME rpz-passthru.
www.anrdoezrs.net CNAME rpz-passthru.
scontent-frt3-1.xx.fbcdn.net CNAME rpz-passthru.
new.net CNAME rpz-passthru.
new.com CNAME rpz-passthru.
In the next iteration again first lines get added again and again.
I need to find a solution -

so that only new entries will get appended.

Any idea folks?latest?d=yIl2AUoC8zA latest?i=iOKv2RQEdMU:EHFGu_5AWCQ:F7zBnMy latest?i=iOKv2RQEdMU:EHFGu_5AWCQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=iOKv2RQEdMU:EHFGu_5AWCQ:gIN9vFwiOKv2RQEdMU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments