Skip to content

Commit 052e1c0

Browse files
committed
example of how to page thru data with raw option
1 parent 3ae4626 commit 052e1c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:
2+
3+
tmp=/tmp/$$_
4+
trap "rm ${tmp}; exit 0" 0 1 2 15
5+
6+
PAGE=0
7+
8+
while true
9+
do
10+
cli4 --raw per_page=5 page=${PAGE} /zones > ${tmp}
11+
12+
domains=`jq -c '.|.result|.[]|.name' < ${tmp} | tr -d '"'`
13+
result_info=`jq -c '.|.result_info' < ${tmp}`
14+
15+
COUNT=` echo "${result_info}" | jq .count`
16+
PAGE=` echo "${result_info}" | jq .page`
17+
PER_PAGE=` echo "${result_info}" | jq .per_page`
18+
TOTAL_COUNT=`echo "${result_info}" | jq .total_count`
19+
TOTAL_PAGES=`echo "${result_info}" | jq .total_pages`
20+
21+
echo COUNT=${COUNT} PAGE=${PAGE} PER_PAGE=${PER_PAGE} TOTAL_COUNT=${TOTAL_COUNT} TOTAL_PAGES=${TOTAL_PAGES} -- ${domains}
22+
23+
if [ "${PAGE}" == "${TOTAL_PAGES}" ]
24+
then
25+
## last section
26+
break
27+
fi
28+
29+
# grab the next page
30+
PAGE=`expr ${PAGE} + 1`
31+
done
32+

0 commit comments

Comments
 (0)