On OpenWrt 10.03.1-RC6 the following command installs iptables stuff:
opkg update && grep -e "Package: iptables-mod-" -e "Package: kmod-ipt-" -e "Package: kmod-nf" -e "Package: .*nfnetlink" -e "Package: .*netfilter" -e "Package: .*iptables" /var/opkg-lists/packages | awk -F ': ' '{print $2}' | xargs opkg install
How can I make this command more compact? (For example with regular expressions.)
You can replace the grep command entirely by this grep command:
grep -E "Package: ((iptables-mod-|kmod-(ipt-|nf))|.*(nfnetlink|netfilter|iptables))" /var/opkg-lists/packages
The -E option specifies grep to use extended regular expressions. The feature of extended regular expressions I am using is:
(c|b)at
This matches "cat" or "bat" i.e. only one of the options in the round brackets are chosen. So in your case the grep command will match
To gain better knowledge of regular expressions please use http://www.grymoire.com/Unix/Regular.html as a reference. Regular expressions form the basis of grep, sed, awk, find and many other UNIX commands. So it is a big advantage if you have a good grasp of regular expressions. Enjoy!