#####
Welcome to the forum.
You have done a good job of writing the script as a learner.
There are some points you could make a note of.
1) repetitive execution of the same commands should be avoided.
2) redundant code should be avoided.
3) printLogoffs and printLogons functions seems to be no use in your case. those are just printing the difference of the files which you already stored.
4) wc would print newlines, words, and bytes for the files. In your case you are taking words (lines should be more safer I guess)
5) print on screen and redirecting to the file both can be achieved on one command with tee. look for it.
who | /bin/awk '{ print $1 }' > check1 #create file to store user details
sort check1 #display users
sort check1 > userlist1 #stored outside loop so it doesn't renew every loop
Could be written as
who | /bin/awk '{ print $1 }' | sort | tee userlist1
wc changesQueryLogoffs | awk '{print $2}'
Could be written as
wc -w < changesQueryLogoffs #count words (as in your command)
wc -l < changesQueryLogoffs #count lines
For printing just the differences ( logon and logoff functions) you could just cat the files. Ditto for logon.
echo "***Following user(s) logged out.***"
cat changesQueryLogoffs
Hope it helps.
Oh man i feel a bit stupid haha ive fixed up a lot of stuff, including your recommendations! Thanks a lot!
I have experience with java but shell scripting was like chalk and cheese haha!