Dear community,
I've a file contaning some logs like:
What I need to do is extract the value in red/bold from the last line with "->". I tried:
But I need only 3101902
Depending on your OS you could also give a try to :
or
Should be faster because starting from end of file
Note that using the tail command without additional options you assume that the line that you want to extract is in the output of your tail command which may not be the case if the number of subsequent "uninteresting" lines exceed 9.
Both of them work perfect! Thanks RudiC and ctsgnb!
Btw, I believe the second one is faster, am I wrong? I'm asking that because the gclog sometime becomes huge!
. . . Btw, I believe the second one is faster, am I wrong? I'm asking that because the gclog sometime becomes huge!
That would be an interesting question. awk will need to go through the entire file to the end to be sure it picks the last number wanted. With tac, you could take the first one and quit. BUT - tac still needs to read the entire file to find the last, before last etc. lines and present them to sed.
And, if there's many a non matching trailing line, this may become slower and slower.
Can you time the solutions with a couple of input files and report back?
EDIT: I created a huge file and did the timing:
Very evident, one order of magnitude difference in execution times. In fact, with strace you can see, that awk opens the file and reads reads reads
, while tac does an lseek (... SEEK_END), (... SEEK_SET) and starts from the rear:
EDIT 2:
is as fast!
I have a log file which have a date and time at the start of every line.
I need to search the log file starting from a specific time to the end of file.
For example:
Starting point: July 29 2018 21:00:00
End point : end of file
My concern is what if the pattern of `July 29 2018 21:00:00`... (3 Replies)
Hi there
I am trying to look for a specific word in the log file and I am aware this can be done by grep for example.
As there will be multiple entries for this I want to grep the last one to enter the log... how would I go about this - would I have to use tail?
Thanks in advance
Alex (4 Replies)
Hi guys
Done a bit of research online but can't seem to figure it out, is there anyway of grepping or using sed to view a specific time period of a log file.
I am trying to view a log file for Saturday 22nd April between 08:00 - 12:00
I saw this command online and tried but doesn't seem to... (10 Replies)
Hi all,
i have a logfile which is continuously being updated. I have built a script to check for a specific content and if it is found, it sends a string into a file. Here's the current script:
#!/bin/bash
logfile=/opt/jboss-eap-6.3/standalone/log/server.log
tail -fn0 $logfile | \... (7 Replies)
Hi All...
I am in need of few columns from a log file.. in .xls file... below is what i have tried.
my log file has 16 colums with " ; " as delimiter, but i need randomn columns 1 2 3 4 5 6 10 11 16 in an excel.
I tried to awk the columns with delimiter ; and it worked, below is the log... (5 Replies)
Hi,
I have log file which rolls out every second which is as this.
HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
I got a huge log in zipped files, i need to write out lines by specific data and if the line with the same contains XML message with the same sessionID will be written to the file to.
The log structure:
2013-08-16 16:31:06,810 ( 122: rogate) INFO - UId:10453, GId:5422: new... (16 Replies)
Hello everyone,
I am on AIX (6.1). I can only use shell (ksh) script.
I can't do this on my own, so will do my best to explain my needs.I also do not know what is the best idea to make it work, so here is what I am thinking, but I may wrong.
I need help to extract info on... (3 Replies)
Hi,
I have a .log file in which it has many values. But i need some specific values. How it can be done using Shell Script. Please explain in detail.
Thankx in advance.
Sathish D V. (8 Replies)
Hi guys
I need to retrieve the values in BOLD that I have mentioned in the below log file. I want to store those values in a variable, preferably the same name as the column name in the log file. if you paste the below mentioned log file in a notepad and remove the word wrap.. u will get a... (4 Replies)