Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Separate raw text file (syslog) separated by spaces into fields

Status
Not open for further replies.

rleyba828

Technical User
Sep 29, 2004
53
US
Hi Team,

I just need some advice on how to separate a line of text delimited by spaces into fields. In the example below, I excerpted two lines from my syslog. First line is on may 22 at 4:02:06 AM and the second line is log entry at 4:02:48 AM.

May 22 04:02:46 au01abcd syslogd 1.4.1: restart (remote reception).
May 22 04:02:48 102.2.109.6 info SSL 2010-05-22T04:02:48+10:00 10.2.109.6 <SSL>: HC:

I need to parse the line so that first field is the "Month", second is "day", then "time", then "hostname", and the rest is "Message"

Would appreciate advice on how to do this.

Thanks very much.



 
Also....as a follow up....i don't think I can just use the Left string function as the "hostname" field above is variable length and sometimes the hostname can be quite long. so it appears that my way of delimiting the fields is by sensing the spaces in between them. Thanks.

 
Hi,
Look into the Join ( or Split, I do not have the program handy and can never remember which is which) function..It can create an array of the space separated text in each line and you can then use that to display what you need

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi Turkbear,

Thanks for this. I'll look it up. It's good to know there's already a built-in function for this.

Thanks again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top