First I beg your pardon for being offline three consecutive days since my provider dropped my line and returned to work just today . That turned me into countless tries about the awk-statement, without a result that is close to my target.
Second, I never said the uptime is linked to any user being logged in or using the computer. Though the given output above shows three users, it is me,myself and I that uses this computer. I always said the uptime just as it is, the computer being switched on and probably connected to the net. The output of time as a sum or an average should be hhh:mm, nothing more. That means for example 123 (hours) : 23 (minutes). Or 123:23. Does this collide with my target to measure the n times before? Your fourth point matters to me, because I said above that my aim is to switch the MAC and perhaps make a redial after a certain time.
Actually now the bash is running your given command and I'll wait to respond to pass you that output as well as my desired output. Meanwhile I will study your source-code. Thanks for your persistence!
---------- Post updated at 08:50 PM ---------- Previous update was at 07:39 PM ----------
So here it is, as I hope the way you expected it. This is my version, setting the date at the end. The last three lines. What I want is to sum up the third row, the format should be hhh:mm. After trying this, it stumbled upon double digits in that row and stopped at something like 7:56, but that surely is not the maximum of that row.
That is what it writes until now, my own script. So I ran your code to see the result and return the output of your last command. As it is the first twelve lines
the last five lines of your given command
and the last lines of the update to the uplog.txt file
What do you mean by the text marked in red above? I thought you wanted to get the sum and average values of the 3rd FIELD (not ROW) from the last 7 and 30 lines??? And, this is the first you have said about wanting a maximum instead of a sum and average???
When I asked you to run uptime for a couple of hours, what we need to see is what happens around multiples of one hour and around an integral multiple of one day of up time. So, instead of skipping over the data between what you showed us:
show us what is on the lines starting with 19:58, 19:59, 20:00, 20:01, and 20:02. And we need to see what happens around the time when the system has been running for an even multiple of 24 hours. (At least on OS X, the format on one hour multiples, is something like 9 hours, 17 secs, (instead of 9:00,) and on 24 hour multiples the change is even more pronounced.)
If you got the output:
from my script, I obviously left in a debugging statement that I forgot about. Note also that the output here says that that the 1st 16 lines from that file were discarded (thereby keeping the last 200 lines) as you requested. Is the last line in your log file:
in the format you want?
Obviously, the format I used to write the sums and averages in /home/averages.txt (or whatever pathname you changed it to) is not in the format you want. But, as I said before, I made a wild guess at a reasonable output format based on the data being summed and averaged. If you will actually show us the last few lines of your log file AND show us exactly what the corresponding sum and average output should be for those lines, we might be able to produce data in the format you want. Did you even look in this file to see the output my script produced?
PLEASE DON'T TELL ME I WROTE THE WRONG SUMS AND AVERAGES IF YOU REFUSE TO SHOW US WHAT YOU WANT!
As I said before, your command:
tells you absolutely nothing about the data on the last 7 or on the last 30 lines in your log file; it is looking for the maximum value in all 200 lines in your log file. And, it is doing a string comparison (not a numeric comparison of hours and minutes); so 7:56 is greater than 22:30, but even more importantly $3 seems to be what you want for looking at the output from uptime not the data in your log file where I hope the up time is in field 5:
shown in red here; not field 3 shown in orange. Or, have you changed the data format in your log file again!
I have a file which is one big long line of text about 10Kb long.
Can someone provide a way using awk to introduce carriage returns every 40 chars in this file.
Any other solutions would also be welcome.
Thank you in advance. (5 Replies)
Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (4 Replies)
I have a file with 8 fields. I need the subtotals for fields 7 & 8 when field 5 changes.
cat wk1
01/02/2011/18AB/17/18/000000071/000000033
01/02/2011/18AB/17/18/000000164/000000021
01/02/2011/18AB/17/18/000000109/000000023
01/02/2011/28FB/04/04/000000000/000000000... (2 Replies)
Hi,
Here i have to check first record $3 $4 with second record $1 $2 respectively. If match found, then check first record $2 == second record $4 , if it equals , then reduce two records to single record like as desired output.
Input_file
1 1 2 1
2 1 3 1
3 1 4 1
3 1 3 2
desired... (3 Replies)
Hi,
how do i read a file using awk for a given no of line?
e.g
1. read only first 50 line.
2. read starting from line 20 to line 60..
thanks in advance.
-alva (8 Replies)
I want to count lines of a file using AWK (only) and not in the END part like this awk 'END{print FNR}' because I want to use it.
Does anyone know of a way?
Thanks a lot. (7 Replies)
Sorry for the weird title but i have the following problem.
We have several files which have between 10000 and about 500000 lines in them. From these files we want to remove lines which contain a pattern which is located in another file (around 20000 lines, all EAN codes). We also want to get... (28 Replies)
The output of an awk script is the below file. Line 1,3 that starts with the Ion... need to be under line 2,4 that starts with R_. The awk runs but no output results. Thank you :).
file
IonXpress_007 MEV37
R_2016_09_20_12_47_36_user_S5-00580-7-Medexome
IonXpress_007 MEV40... (6 Replies)
The awk below executes and is close (producing the first 4 columns in desired). However, when I add the sum of $7, I get nothing returned. Basically, I am trying to combine all the matching $4 in f1 and output them with the average of $7 in each match. Thank you :).
f1
... (2 Replies)