#!/bin/bash#function name "readfile"readfile (){#function begins here#declare variablesDIR=/home/chopseuy/bin/routeractivity/ra-logs/ #directory where logfiles are kept #if you want to specify the full path make sure #that you begin with "/" #also must always end in "/"LIMIT=3 #loop limit or number of tty to compare#loop begins herefor ((a=1; a <= LIMIT ; a++)) # Double parentheses, and "LIMIT" with no "$".doTTY$a=`cat $DIR* | grep "$a tty $a" |wc -l`echo "tty $a = $TTY"done#function ends here} #close bracket for function close#check the logfiles first before running the scriptif [ -a "$DIR/" ]thenreadfileelseecho "directory does not exist"fi