BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 24th, 2009, 12:26 PM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 575 fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 10 h 47 m
Reputation Power: 383
Awk RS trouble

I'm currently to adapt a script to parse through our mail servers' mailq output to display various stats, but one server is giving me some troublesome output that is difficult to parse with awk.
Code:
23 Sep 2009 22:09:31 GMT  #26200266  3106535  <user@external.com>
        local   internal.com-user@internal.com
23 Sep 2009 12:53:56 GMT  #26201531  1616  <>
        local   internal.com-user@internal.com
24 Sep 2009 01:51:22 GMT  #26200795  2862  <user@external.com>
        remote  user@external.com
On the other servers I've been working on there is an extra newline between each record that's much easier to catch, but this has proven to be much more difficult. I've run the output through hexdump hoping there might be an extra CR character I can latch on to, but it's purely \n with a \t stuck in the middle of the record on the second line.

I would be very appreciative if someone could help me out with a proper RS to chunk this down into the correct, bite-sized pieces.

TIA
__________________

Reply With Quote
  #2  
Old October 4th, 2009, 01:33 PM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 575 fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1Folding Points: 444419 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 10 h 47 m
Reputation Power: 383
Bumpdate:

A coworker suggested a different approach to the problem, where I should just replace the occurences of \n\t with something else to put all the info for each record on one line, and go from there.

Naturally I looked into sed and/or tr, but I'm having far too much trouble catching the newline with a sed expression, and tr replaces \n and \t separately, as opposed to as one entity.

Ideally I'd like to use:
Code:
sed 's/\n\t/X/g'
but for some reason the escape sequences do not seem to work as expected.

I've moved on to a backquoted printf to insert the literal characters into the expression:
Code:
sed "`printf 's/\\\n\t/X/g'`"
which does work to catch the tab charater, but ignores the newline.

I've realized that this is most likely due to sed's behaviour of reading input one line at a time, without the newline. While I can see this potentially causing a memory issue, is it at all possible to get sed to read the input all in one go, as opposed to line by line?

I am open to other lines of thought as well, should anyone have another method in mind.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Awk RS trouble

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap