Commit f9cee05c authored by frozar's avatar frozar

[DEV] Add a new script to sort subroutine of a file by length.

parent da0fa083
#!/bin/bash
usage(){
# display the number of argument given
# echo $#
echo " Usage:" $0 "<file_name>"
}
if [ $# -ne 1 ]
then
usage
exit -1
fi
f=$1
sub_names=`grep -i subroutine $f | grep -v -e " *\!.*" -e " *end *subroutine" | grep subroutine | python -c "import sys; l = map(lambda x: x.split(), sys.stdin.readlines()); print '\n'.join(map(lambda x : x[1], l ))" | cut -d"(" -f1`
( for sub in ${sub_names}
do
beg=`grep -ni "subroutine" $f | grep "${sub}" -A1 | head -n1 | cut -d":" -f1`
end=`grep -ni "subroutine" $f | grep "${sub}" -A1 | tail -n1 | cut -d":" -f1`
echo -e "$(( $end - $beg + 1 ))\t: $sub"
done ) | sort -rn
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment