Skip to content

Instantly share code, notes, and snippets.

@ldante86
Last active November 9, 2016 05:47
Show Gist options
  • Save ldante86/4a4c5c565f07f0197cda81cddccdeb7b to your computer and use it in GitHub Desktop.
Save ldante86/4a4c5c565f07f0197cda81cddccdeb7b to your computer and use it in GitHub Desktop.
html version of btags.sh
#!/bin/bash -
if [ ! "$1" ]; then
exit 1
fi
in_file="$1"
if [ ! -e "$in_file" ] || [ -d "$in_file" ]; then
exit 1
fi
egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" >/dev/null || exit 1
lineno=()
fname=()
echo "<table style=\"width:50%\" border=\"1\">"
echo "<tr>"
echo "<th>Functions for $in_file</th>"
echo "<th>Line Number</td>"
echo "</tr>"
for i in $(egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" | awk -F ":" '{print $1}')
do
lineno+=( "$i" )
done
for i in $(egrep -on '[A-Za-z0-9_]+[(]+[)]' "$in_file" | awk -F ":" '{print $2}')
do
fname+=( "$i" )
done
n=0
for i in `echo "${fname[@]}" | tr -d '()'`
do
echo "<tr>"
echo "<td>$i</td>"
echo "<td>${lineno[n++]}</td>"
echo "</tr>"
done
echo "</table>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment