Re: Help with a Bash script

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/04/10 16:06, Michael Thompson wrote:
> I'm quite new to Bash scripting, and just need a little pointer on how
> to go through a file, and execute commands there in until the end of the
> file is reached.
> 
> The idea is this, a list of iptables rules is downloaded, they are run
> through a set of commands to get the file in a state ready to run. I
> need to read each line of that file, and execute each one. I'm not sure
> on loops in bash, and hope someone can help... :)
> 
> I download this file:
> http://www.okean.com/antispam/iptables/rc.firewall.china
> 
> Then run it through this to sanitize it
> sed 's/--dport 25//g' rc.firewall.china|cat|grep "^[ ]*iptables" >
> rc.firewall.china_mod
> 
> Now, how do I loop through that file executing each line in a for while
> loop?
> 

Sorted.

#!/bin/bash
wget http://www.okean.com/antispam/iptables/rc.firewall.china
sed 's/--dport 25//g' rc.firewall.china|cat|grep "^[ ]*iptables"|sed
's/INPUT/China/g' > rc.firewall.china_mod
chmod +x rc.firewall.china_mod
./rc.firewall.china_mod

- -- 
Michael
http://maverickapollo.wordpress.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJLvfYCAAoJEEcwpNahApVBx7MIALEvkNGKvazDnclBvp7sLGHl
BAz0cSPwRkuBRCip6GiInfm9OVtFw+3fCbByCV70tN4tg9i1D7f2Roaj7NAtCBw6
o65L1BBo+b1JEvvdIQo58PzNKJYfVGG8ZX55SyXoHHPG5SZRiNokzR0lM92U1xOa
i+gBH2Dsl3UxYda3qeQnnkCD+qgITUkKgqrjbxDPfDtBmnmo43tiplbdYjH4XDor
ox4qfdfsTHREUoB6/jCQTlp3tVnbYBLvY+PRpLRAUATjl010IZggEIkLVTsAnPqC
7vg4X2hED9C80jlyZ6EqSDaYhvP3nlZqPLLh1AYwwEdzEX1XynjuYyHNz9qpJsI=
=3O0e
-----END PGP SIGNATURE-----
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux