On February 9, 2003 05:16 pm, you wrote:
> Is anyone willing to put together a quick shell or perl script for me,
> preferably shell? It should be pretty simple, and I could probably figure
> it myself given enough time, but I am in a bit of a rush with something and
> I think its pretty simple for the "real" coders on this list.

Here's something that is very rough but gets the job done. There is no error 
checking and there is a chance of false matches. I didn't put in any regular 
expressions to do better matching. This means if twtest.txt contains 
"/bin/ls" for example and twpol.txt contain "/bin/ls2" it'll still be matched 
and /bin/ls2 will be commented out.

I'm counting that your files don't have these clost matches so it might work 
fine for ya. If it doesn't do the job properly (make backups of the tw*.txt 
files) let me know and I can put in a bit more time to do it.

Anyway here it is, doesn't get much shorter (4 lines):

for line in $(cat twtest.txt); do
        sed "s|^$line|#$line|" twpol.txt > twpol.txt.new
        mv twpol.txt.new twpol.txt
done


-- 
Gerard Beekmans
www.linuxfromscratch.org

-*- If Linux doesn't have the solution, you have the wrong problem -*-

Reply via email to