Share this on:

4 comment

  1. plz help me out.i want to write a linux shell that counts the number of user accounts both normal and privileged user accounts

  2. That seems kind of kludgy. In the first place using “echo” as a variable name isn’t a good idea since it’s also a shell command. Using “line” as a variable has the same problem. You can also break long quoted strings over many lines and just invoke echo once.

    function whoson(){
    echo -n “*************************************************\n
    your username : $USER\n
    Current date and time : `date +”%A %d %B %Y at %H:%M”`\n
    Currently logged on users:\n”

    Use function name anywhere in a script or call it repeatedly or as a sub-routine by just using the function name, “whoson”. Notice that each line ends with a \n which is correctly displayed as a newline if you use the -n option to echo. All the lines will display correctly if properly quoted. The date format is just friendlier.


Leave a Comment