Hello all, I am wondering how it is possible to do the following: set month=`date | cut -c5-7` set userInfo=`last "$1" | grep "$month"` echo $userInfo <---- how do I to put each line on a separate newline? SO that when I echo this variable (echo $userInfo)- It displays identically to just invoking the last command. For example, last username. At the present time, when this command is invoked it appends each new line to the preceding line. I need to iterate over the contents stored in this variable to process the times(add them).
Some background; I am trying to write a sh script to count how many hours a given user has used the system since this month. However, I run into a sling when I try to use a for loop. I believe I need to correct the problem of echo $userInfo displaying each line as a separate line to use in the for loop; but not 100% certain. I know I need to process the login times from the last command in a for loop and add them(just increment the sum of a variable). And I know that I'll have to implement an if elif clause to test different critera. Any suggestions, greatly appreciated. Thanks in advance.