forked from dnshi/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadme.sh
More file actions
33 lines (23 loc) · 778 Bytes
/
readme.sh
File metadata and controls
33 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
function usage()
{
echo -e "Usage: ${0} [file]"
echo -e ""
echo -e "Example:"
echo -e ""
echo -e " ${0} ./LargestNumber.cpp"
echo -e ""
}
if [ $# -lt 1 ] || [[ ! -f ${1} ]]; then
usage
exit 255
fi
DIR=`cd $(dirname ${1}) && pwd -P`
FILE=${DIR}/$(basename ${1})
URL=`grep Source ${FILE} | awk '{print $4}'`
title_str=`xidel ${URL} -q -e "css('div.question-title h3')"`
NUM=`echo ${title_str} | awk -F '.' '{print $1}'`
TITLE=`echo ${title_str} | awk -F '.' '{print $2}' | sed -e 's/^[[:space:]]*//'`
DIFFCULT=`xidel ${URL} -q -e "css('.question-info')" | grep Difficulty | awk '{print $2}'`
FILE=`echo ${FILE} | sed "s/.*\/algorithms/\.\/algorithms/"`
echo "|${NUM}|[${TITLE}](${URL}) | [JavaScript](${FILE})|${DIFFCULT}|"