Sponsored Content
Top Forums Shell Programming and Scripting Read multiple lines at a time from file Post 302828927 by anbu23 on Wednesday 3rd of July 2013 01:42:47 PM
Old 07-03-2013
Code:
$ awk -v RS='\n\n' -v ORS='\n\n' ' { print NR":" $0 } ' file
1:dn: cn=user1,ou=org,o=org
cn=user1
uid=user1

2:cn=user2,ou=org,o=org
cn=user2
uid=user2

3:cn=user3,ou=org,o=org
cn=user3
cn=user33
uid=user3

4:cn=user4,ou=org,o=org
cn=user4
uid=user4

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read and match multiple lines in perl

Could any one tell me how to read and match multiple lines in perl? Did this code below still work in this situation? while (<FILE>) { if (/ /) { } } Thanks a lot! (5 Replies)
Discussion started by: zx1106
5 Replies

2. Shell Programming and Scripting

How to read and compare multiple fields in a column at the same time

Hi, Currently I am coding up a nasty way of reading file input using *cat* rather than *read*. My text input looks like TextA 100 TextB 110 TextC 120 Currently I am using cat |while read line to read the first column and second column fields. cat foo.txt|while read line do ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

3. Shell Programming and Scripting

Read multiple arguments in for loop each time

Hi, Guys I am new to shell programming and just get stuck with one simple question. please kindly help. According to the tutorial here, we can do something like for NODE in "ABC 10" "EFG 20" do set -- $NODE echo "letter is $1, number is $2" done And the result will... (3 Replies)
Discussion started by: yuanli
3 Replies

4. Shell Programming and Scripting

How to read a multiple lines from a file n executing them?

Hi all, I am just trying to read the contents of a file. basically this file has a list of dat files. then i want to access these dat files n execute a script on them one by one using a loop. i hav e written like this ls -l | cut -c 58-88 > file1.txt while do arr1="$( sed -n '1p'... (7 Replies)
Discussion started by: navjyotisonu5
7 Replies

5. Shell Programming and Scripting

read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field. example input line: ... (2 Replies)
Discussion started by: erlanq
2 Replies

6. Shell Programming and Scripting

read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field. example input line: ... (1 Reply)
Discussion started by: erlanq
1 Replies

7. Shell Programming and Scripting

read the lines of multiple files

I am trying to create a script which will read 2 files and use the lines of file 1 for each line on file 2. here's my sample code cat $SBox | while read line do cat $Date | while read line do $SCRIPTEXE <line from first file> $2 <line from 2nd file> ... (12 Replies)
Discussion started by: khestoi
12 Replies

8. Shell Programming and Scripting

Read two lines at time from a file

Hello community, what I need to do is read 2 rows at time from a file. I have this simple solution: File to read: LINE1 LINE2 LINE3 LINE4 LINE5 LINE6 LINE7 LINE8Read routine:#!/bin/ksh sed '1,3d' /out.txt | while read line; do read line2 echo $line $line2 doneResult:LINE1... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

9. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

10. UNIX for Beginners Questions & Answers

How to read multiple files at same time through UNIX scripting?

How to read multiple files at simultaneously? (1 Reply)
Discussion started by: Priyanka_M
1 Replies
POSTGREYREPORT(1)					User Contributed Perl Documentation					 POSTGREYREPORT(1)

NAME
postgreyreport - Fatal report for Postfix Greylisting Policy Server SYNOPSIS
postgreyreport [options...] -h, --help display this help and exit --version display version and exit --user=USER run as USER (default: postgrey) --dbdir=PATH find db files in PATH (default: /var/lib/postgrey) --delay=N report triplets that did not try again after N seconds (default: 300) --greylist-text=TXT text to match on for greylist maillog lines --skip_pool Skip report for 'subscriber pools' ( last 2 octets of IP found in PTR name ) --skip_dnsbl=RBL RBL server to query and skip reporting for any listed hosts (SLOW!!) --skip_clients=FILE PTR or IP or REGEXP of clients to skip in report --match_clients=FILE *ONLY* report if fatal *AND* PTR/IP of client matches --show_tries display the number of attempts failed triplets made in first column --show_time show entry time in maillog (single line only) --tab use tabs as separators for easy cut(1)ting --nosingle_line display sender/recipients grouped by ptr - ip --separate_by_subnet=TXT display TXT for every new /24 (ex: "================= " ) --separate_by_ip=TXT display TXT for every new IP (ex: " ") --check_sender=LIST one or more of: mx,mx/24,a,a/24 does DNS/A lookups for sender @domain and compares sending IP if match displays "MX" "A" or "MX/24" or "A/24" depending on LIST Note that --(skip|match)_clients can be specified multiple times and there are no default files. Same rules apply as postgrey's --whitelist-clients, see postgrey doc for more info. --skip_dnsbl can also be specified multiple times to query multiple DNSBL servers. DESCRIPTION
postgreyreport opens postgrey.db as read-only; reads a maillog via STDIN, extracts the triplets for any Greylisted lines and looks them up in postgrey.db. if the difference in first and last time seen is less than --delay=N then the triplet is considered fatal and displayed to STDOUT The report sorts by client IP address Note: unless you are using --lookup_by_subnet or excluding all known MTA pools you will likely have false fatal reports for "BigISPs". A message that was tried from every IP in SMTP pool before making it through will show up in the report for all of the attempted source IPs USAGE It is best to run postgreyreport against a maillog that is at least several hours old (yesterdays?) ( you be the judge on how old is acceptable ). if you run the report against a live maillog you are not giving legit MTA's enough time to try again and you will have lots of inaccurate information. o Ex usage: zcat /var/log/maillog.0.gz | ./postgreyreport [options] > postgreyreport.log or zcat /var/log/maillog.0.gz | ./postgreyreport --nosingle_line --check_sender=mx,a --separate_by_subnet=":================== " # 94 "=" total, some were omitted for clarity o Ex Output: ( POD wrapping will mess this up, view source ) :============================================================================================ unknown 4.29.43.31 marissa_mcclendonuu@abit.com.tw user1@recipient1.com jake_meyerdt@ali.com.tw user2@recipient1.com jenny_banks_sh@translate.ru user1@recipient2.com rvazquezpo@ali.com.tw user3@recipient1.com aep@notimexico.com user2@recipient1.com brittneystanley_ei@cetra.org.tw user2@recipient1.com brendasheehan_cw@lib.ru user2@recipient1.com :============================================================================================ lsanca1-ar5-127-189.biz.dsl.gtei.net 4.33.127.189 A fokkensr@lsanca1-ar5-127-189.biz.dsl.gtei.net user2@recipient1.com cyxlfrfwciercu@publicist.com user3@recipient4.com :============================================================================================ smtpout.mac.com 17.250.248.83 do_not_reply@apple.com user4@recipient5.com smtpout.mac.com 17.250.248.88 MX legituser@mac.com user6@recipient7.com :============================================================================================ HISTORY
1.14.3 20100321 Some additions, Leonard den Ottolander <leonard.den.ottolander.nl> New option: --tab Use tabs as separator in single line mode New option: --show_time Show entry time in maillog in single line mode 1.14.2 20040715 BUGFIX: (automatic) lookup-by-subnet support was broken, fixed. BUGFIX: corrected a few spelling errors new Option: --skip_pool Skip report for 'subscriber pools' 1.14.1 20040712 Changed --return-string to --greylist-text to match postgrey new Option: --skip_clients=FILE new Option: --match_clients=FILE new Option: --skip_dnsbl=RBL.DNS.NAME All 3 of the new options can be specified multiple times. Updated do_*_subsititions again to match postgrey 1.11.1 20040701 missing keys from DB are considered fatal triplets and included in report Changed --delay testing from "greater than" to "greater than or equal to" Fixed --help and --man switches Removed setuid Notice 1.6.4 20040618 Initial Public Version (postgrey/contrib) AUTHOR
Tom Baker <tbaker@bakerfl.org> perl v5.14.2 2012-02-03 POSTGREYREPORT(1)
All times are GMT -4. The time now is 01:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy