how to fetch the logs from the log files

srikotesh
srikotesh used Ask the Experts™
on
Hi Experts,

1.
test/xml
under this folder i have 100 xmls
i want to see specific tags along with value
 <empid>100</empid> .. so on
how to fetch using linux command .

2.while fetching logs
how to use more command
more info.log i am giving this command logs are showing .
after that how to trace a specific word

example:
more info.log
'textexample' i want to seach this word.

3.when to use more command and when to use less command.

suggest me best ways to trace the logs .
when log file size very huge and log is written in multiple files(i mean if i want to find logs in current and old files) how to fetch the specific word from all the logs.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Question 1 and 3 are basically the same:

use the "grep" command ex.

grep <empid>100<//empid> *.xml


2. Use the "less" command instead, fire up search by using this on the keyboard (forward slash): /
David FavorFractional CTO
Distinguished Expert 2018

Commented:
1) XML Parsing: You might be able to use html2text for this.

2) Log Parsing: cat logfile | grep textexample

3) Which command to use: The commands more + less are generally equivalent. The less command is more recent + tends to run much faster than more, across very large files. Either may be used, for the most part, interchangeably.
Mark GeerlingsDatabase Administrator

Commented:
"The commands more + less are generally equivalent."

That has not been my experience.  I'm not a Linux expert, but we use Linux to run our Oracle database servers so I'm somewhat familiar with Linux.  With the "more" command, I can only advance through large files, one screenful at a time.  The "less" command also supports advancing through large files, one screenful at a time just like the "more" command does, plus it allows me to scroll back up, either by line or by a screenful at a time.  The "more" command does not allow scrolling back up, at least in the RedHat/Oracle versions of Linux that I've seen.

I've never noticed nor tested for a performance difference between them.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

David FavorFractional CTO
Distinguished Expert 2018

Commented:
As I said, "The commands more + less are generally equivalent."

More or Less != Same.

At this point less is provided with every Distro + has been for years.

Most .bashrc startup files do something like...

which less >/dev/null 2>&1 && alias more=less

Open in new window


Also less does have many more options...

https://www.topbug.net/blog/2016/09/27/make-gnu-less-more-powerful/ covers a few... and...

More + Less are still basically the same. The present a file page by page.

Also of note is the view command which is runs vi in read only mode. This provides even more complex file movement than more or less.

Author

Commented:
hi kimputer/Experts,

as you said
 grep <empid>100<//empid> *.xml
this cmd will fetch the above tag alone

what I am asking is  I have 100xmls
I don't know the emp id's
I want all 100 emp id's from the list of  xmls

Commented:
grep -E <empid>[0-9]{1,3}<//empid> *.xml

(the 3 can be bigger, if 999 is NOT your max value)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial