-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmax-depth.sh
More file actions
44 lines (36 loc) · 720 Bytes
/
max-depth.sh
File metadata and controls
44 lines (36 loc) · 720 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
34
35
36
37
38
39
40
41
42
43
44
#
while getopts 'xh' opt; do
case "$opt" in
x)
set -x
;;
?|h)
cat - <<EOF
NAME
$(basename $0) - get the depth of the deepest node in the parse tree
SYNOPSIS
$(basename $0) ([-x | -h])* [files]
DESCRIPTION
This script must be run under Linux Bash or Windows MSYS2 Bash or Windows WSL Linux.
OPTIONS
-h
Output this help message.
-x
Execute "set -x" to debug script.
EXAMPLE USAGE
EOF
exit 0
;;
esac
done
shift $((OPTIND - 1))
files=("$@")
temp=`mktemp`
if [ ${#files[@]} -gt 0 ]
then
trparse ${files[@]} > $temp
else
cat - > $temp
fi
cat $temp | trxgrep ' max(//*[not(*)]/count(ancestor::*))'
rm -f $temp