Get a wiki page information Shell gets the wiki subdirectory information-shell

Source: Internet
Author: User

#!/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#&nbsp;\|</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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.