A scripting question (harder than I thought)
William Park
opengeometry-FFYn/CNdgSA at public.gmane.org
Sun Feb 29 03:54:09 UTC 2004
On Sat, Feb 28, 2004 at 08:02:53PM -0500, Walter Dnes wrote:
> I use the aggregate sorbs zone to cut down on DNS traffic. Sorbs
> has that IP address listed under 4 categories, and returns 4 lines.
> Do I need to use Python or something similar ?
While I'm at it... If you follow line-by-line approach, then Python
script will not be that different from shell/sed/awk. A different
approach would be to read the whole file and split out the blocks as
string.
1. In Python,
all = open('logfile', 'r').read()
a = all.split('\n\n')
for i in a:
print i.replace('\n\n', '')
2. Using my Bash patch,
http://home.eol.ca/~parkw/index.html#bash
you would do something similar,
all=`cat logfile`
a=()
array -j $'\n\n' a "$all"
printf '%s\n' "${a[@]//$'\n'/}"
--
William Park, Open Geometry Consulting, <opengeometry-FFYn/CNdgSA at public.gmane.org>
Linux solution for data management and processing.
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list