2
xia0u
7y

Help is welcome - I don't get it x.x
Just started scripting and can't find it on google:
Got a little whitelist with urls in it and a huge list with urls in it.

whitelist format:
foobar.com
barfoo.au

format huge list:
blabla=/foobar.com/wo.op
blabla=/barfoo.au/wo.op
blabla=/barfoo.crazy.au/wo.op

blabla/barfoo.crazy/wo.op
should stay in the file.

Now I want to delete the entries of the whitelist from huge list.
I have no clue how I can get the
foobar.com
into
sed -i '/foobar\.com/d' $file
to make it work in my script x.x

Comments
  • 0
    @moshmage
    Your comment made me look at the files again, think it over and get a good starting point without googlin.
    Sorry for crieing, but anyway:
    Thanks
  • 1
    (just the general programming idea, I'm not a great bash scripter)
    foreach(whitelistlines as $line)
    {
    sed -i -e 'g/$line/signforwhitespaceandnextline/g'
    }

    Something like this maybe?
  • 0
    @linuxxx
    I can't use the whole line as $var since I have to find the "." and escape them to "\." and put that into a tmp-file or something maybe.
    We'll see.

    Haven't go on with that little project, but will come back here when I did.
    Thanks for ya effort
  • 2
    @xia0u No problem, update us when you have a solution if possible!
  • 0
    @linuxxx

    Ok, you got me to it xD

    cat $testfile
    carz.com
    foobar.de
    amazon.need.com
    foo.bar.g.au
    flickflick.it

    Now let sed find all dots (/\.) and replace them with "\." (/\\.).

    sed -e 's/\./\\./g' $testfile.txt
    (-e to have output on screen and nothing is changed in the file)
    output:
    carz\.com
    foobar\.de
    amazon\.need\.com
    foo\.bar\.g\.au
    flickflick\.it

    In the script I'll use -i to let sed edit the file right away.
    sed -i 's/\./\\./g' $testfile.txt
Add Comment