Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
(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? -
xia0u658y@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
Related Rants
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
undefined
bash
script
sed
newbie
help me