Is it possible to know the number of sections in a config file under /etc/.
For example for the file /etc/config/application, the command "uci show application.@section" returns all the options under section 1.
In similar way, using UCI, is there any command which returns number of sections in config file.
Now to check whether the execution has reached end of file or not, is to run by incrementing the sections number until it reaches "uci: Entry not found"
Not a particularly nice way of doing it, but:
uci show firewall | grep "firewall.@section.*=section" | wc -l
and subtract 1 from that number.
while uci -q get application.@section[$n_sections] >/dev/null; do
n_sections=$((n_sections + 1))
yet another one ... without uci, pipes etc. ...
grep -c "^config" /etc/config/firewall
If my guess that you're trying to iterate over config file is correct, I'd highly recommend you consider using the
config_cb and the like callback options described here.