#!/bin/bash
##################################################
##################################################
Set-e
# #需要参数
If [$#-eq 0];then
echo "requires parameters, such as command below"
echo "Sh $0-h"
Exit 1
Fi
# #shell需要jq命令
#apt-get install-y JQ 1>/dev/null 2>&1
# #获取 Wiki tower record, download to local towercount.js ##############################################
Wget-o towercount.js "Http://xxurl/wiki/page.json?pageid=xx" 2>/dev/null
# #获取id, title, URL, and displayed on the page
Cat Towercount.js |JQ. |grep-e "Id|title|url"
# #获取tower内容, and write to file
Cat towercount.js |jq data.content |sed ' s#<p>\|<br/>#\n#g ' |sed ' s# \|</p>\| ' \|style=\color# #g ' |sed '/^$/d ' > TowerContent.txt
# #对tower内容, perform conditional output
While getopts "N:d:ah" arg
Do
Case $arg in
N
Head-n $OPTARG TowerContent.txt
;;
D
Head-n1 Towercontent.txt;cat Towercontent.txt|grep $OPTARG
;;
A
Cat TowerContent.txt
;;
H
echo "sh $0-n num (number of lines), showing the last n days of records sh $0-n 2"
echo "Sh $0-d date shows this day's record example:sh $0-d 2017-8-01"
echo "Sh $0-a Show All records Example:sh $0-a"
echo "sh $0-h display Help Example:sh $0-h"
;;
?)
echo "unkonw argument; SH $0-n num (number of lines) or-d 2017-08-12 or-a "
;;
Esac
Done
Get a wiki page information Shell gets the wiki subdirectory information-shell