On February 10, 2003 01:16 pm, you wrote:
> On February 9, 2003 10:38 pm, you wrote:
> > sounds like twtest.txt has a 'Filename: ' prefix on each line, so you
> > may wanna insert a line like this before the sed command
>
> I simply assumed there wouldn't be a "Filename:" string in the twpol.txt
> file. I know the loop gets more "expensive" this way since guaranteed half
> the sed calls will not do anything, but oh well it was quicker that way :)

Oh something else to note, 'cat' doesn't read an entire line in, but rather 
something that is better classified as words. Here's the code again:

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

The first iteration will contain "Filename:" and will be matched again 
twpol.txt but won't match anything. It'll then continue and $line will 
contain whatever was after Filename: which would be "/sbin/accton". The the 
3rd run it'll go to line #2, word #1 which is Filename: again and the 4th run 
is line #2 word #2 which is the filename /scsi/proc and so on.

Maybe rename the line variable to 'chunk' or 'word' or something.

-- 
Gerard Beekmans
www.linuxfromscratch.org

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

Reply via email to