Re: Bash Script for Beginners! oh dear :'(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



For those interested here is an updated version of my script but still
no luck :(

#!/bin/bash
rm -f ./found_files
touch ./found_files
find . -exec grep -q "$1" '{}' \; -print >> ./found_files
i=1
while [ $i -le `wc -l found_files` ] ; do
    line=`head -$i found_files | tail -1`
    grep -iv "$1" $line > $line.new
    rm $line
    mv $line.new $line
    i=`expr $i + 1`
done


2008/12/23 James Bensley <jwbensley@xxxxxxxxx>:
> Hey guys,
>
> I'm a bit of a beginner (understatement!) with shell scripting and
> seek help! I am setting up our new squid proxy. Its working a treat
> and squidGuard is the icing on the cake. But, I am trying to write a
> shell script to search through our black list category's for
> squidGuard and remove the parsed value;
>
> Scenario:
> /some/directory/where/blacklist/is/stored contains about 40-50 folders
> called, adult, gambling, banking, warez etc. There is a folder for
> each blocking category (and in each folder is two files, urls and
> domains, standard stuff for web filtering!)
>
> I have a script to search through
> /some/directory/where/blacklist/is/stored and look at each text file
> trying to find someblockedsite.com and remove it. This is as far as I
> have got:
>
> machine:/blacklistdir# sh ./find_files "blockedsite.com"
>
> find_files is as follows:
>
> #!/bin/bash
> rm -f ./found_files
> touch ./found_files
> find . -exec grep -q "$1" '{}' \; -print >> ./found_files
> i=1
> while [ $i -le `wc -l ./found_files` ] ; do
>
>    grep -iv $1 $2 > $2.new   ####This is where I am stuck, I have put
> $2 but I want to be reading each line of text from found_files?
>    rm $2
>    mv $2.new $2
>
> done
>
> But I am totally stuck! My questions to this awesome list are: can
> someone help my with my script? And, if so, can you explain to me how
> you have achieved your solution?
>
> Thanks a lot for reading guys n gals its greatly appreciated.
>
> Regards,
>
> James.
>
> -----BEGIN GEEK CODE BLOCK-----
>  Version: 3.1
> GIT/MU/U dpu s: a--> C++>$ U+> L++> B-> P+> E?> W+++>$ N K W++ O M++>$ V-
> PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+> DI D+++ G+ e(+++++) h--(++) r++ z++
> ------END GEEK CODE BLOCK------
>



-- 
-----BEGIN GEEK CODE BLOCK-----
  Version: 3.1
GIT/MU/U dpu s: a--> C++>$ U+> L++> B-> P+> E?> W+++>$ N K W++ O M++>$ V-
PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+> DI D+++ G+ e(+++++) h--(++) r++ z++
------END GEEK CODE BLOCK------
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux