Sponsored Content
Top Forums Shell Programming and Scripting Use string as Record separator in awk Post 302947635 by cgkmal on Friday 19th of June 2015 04:57:14 PM
Old 06-19-2015
Use string as Record separator in awk

Hello to all,

Please some help on this. I have the file in format as below.

How can I set the record separator as the string below in red
"No. Time Source Destination Protocol Length Info"

I've tried code below but it doesn't seem to work.
Code:
awk 'BEGIN{RS = "No.     Time.*"} ; {print $0}' file

input file:
Code:
No.     Time                          Source                Destination           Protocol Length Info
     28 2015-06-18 12:12:05.727772000 001822                  780568                  XXXXX  198    XXXXX

Frame 28: 198 bytes on wire (1584 bits), 198 bytes captured (1584 bits) on interface 0
    Interface id: 0 (\Device\NPF_{28086D60-7061-4ADD-B9})
    Encapsulation type: Ethernet (1)
	
	
No.     Time                          Source                Destination           Protocol Length Info
     29 2015-06-18 12:12:05.757809000 1.1.1.14          1.1.1.2          MXHHH     62     ZZZZ 

Frame 29: 62 bytes on wire (496 bits), 62 bytes captured (496 bits) on interface 0

No.     Time                          Source                Destination           Protocol Length Info
     30 2015-06-18 12:12:05.759481000 1.1.1.1          2.2.2.20           MHCKK     62     ZZZZ 

Frame 30: 62 bytes on wire (496 bits), 62 bytes captured (496 bits) on interface 0
    Interface id: 0 (\Device\NPF_{28086D60-7061-4ADD-B9A1})

Thanks for any help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

record separator

can anyone tell me any way to change record separator (default is new line). RS in nawk as not working. Thanks in advance. Regards Rochit (7 Replies)
Discussion started by: rochitsharma
7 Replies

2. Shell Programming and Scripting

awk & cut record separator problem

Hi All, I've got some strange behaviour going on when trying to manipulate a file that contains spaces. My input file looks something like this: xxxxxxxxx,yyyy,sss sss sss,bbbbbbb If I use awk: When running from the command line I get: sss sss sss But when running from a... (7 Replies)
Discussion started by: pondlife
7 Replies

3. Shell Programming and Scripting

How to add record separator after certain lines

How to add record separator after certain lines? I am faicing issue where some lines have result as successive line & some are not having. how can I add record separator after every record here is example of data I have (line numbers are not present in data): 1. <enabled="true" name="dSuite1"... (7 Replies)
Discussion started by: sach253
7 Replies

4. Shell Programming and Scripting

awk - double quotes as record separator

How do I use double quotes as a record seperator in awk? (4 Replies)
Discussion started by: locoroco
4 Replies

5. Shell Programming and Scripting

Using > as record separator

I have tried to use ">" as record separator, but it doesn't work. I have tried this: awk BEGIN{RS=">"}'{print $0}' input output: awk: BEGIN{RS=>}{print $0} awk: ^ syntax error awk BEGIN{RS="\>"}'{print $0}' input awk: BEGIN{RS=\>}{print $0} awk: ^ backslash not... (2 Replies)
Discussion started by: locoroco
2 Replies

6. Shell Programming and Scripting

awk, string as record separator, transposing rows into columns

I'm working on a different stage of a project that someone helped me address elsewhere in these threads. The .docs I'm cycling through look roughly like this: 1 of 26 DOCUMENTS Copyright 2010 The Age Company Limited All Rights Reserved The Age (Melbourne, Australia) November 27, 2010... (9 Replies)
Discussion started by: spindoctor
9 Replies

7. Shell Programming and Scripting

apply record separator to multiple files within a directory using awk

Hi, I have a bunch of records within a directory where each one has this form: (example file1) 1 2 50 90 80 90 43512 98 0909 79869 -9 7878 33222 8787 9090 89898 7878 8989 7878 6767 89 89 78676 9898 000 7878 5656 5454 5454 and i want for all of these files to be... (3 Replies)
Discussion started by: amarn
3 Replies

8. Shell Programming and Scripting

awk - single quotes as record separator

How do I use single quotes as record separator in awk? I just couldn't figure that out. I know how to use single quotes as field separator, and double quotes as both field and record separator ... (1 Reply)
Discussion started by: locoroco
1 Replies

9. Shell Programming and Scripting

Replace a string for every record after the 1st record

I have data coming in the below format for each record <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><testdetials>....</test_sox> <?xml version="1.0" encoding="UTF-8" standalone="no"?><test_sox... (8 Replies)
Discussion started by: dsravanam
8 Replies

10. Shell Programming and Scripting

Help with awk regular expression for RS record separator

Hi, I'm using gawk to read a text file and count the sentences. I want to use a record separator of a period, exclamation mark and a question mark. The problem is that the file contains words like "Mr. Smith" so the periods in the appellation are tripping my record separator. This is my... (12 Replies)
Discussion started by: 1Brajesh
12 Replies
Net::EPP::Frame::Command::Info::Host(3pm)		User Contributed Perl Documentation		 Net::EPP::Frame::Command::Info::Host(3pm)

NAME
Net::EPP::Frame::Command::Info::Host - an instance of Net::EPP::Frame::Command::Info for host objects. SYNOPSIS
use Net::EPP::Frame::Command::Info::Host; use strict; my $info = Net::EPP::Frame::Command::Info::Host->new; $info->setHost('ns0.example.tld'); print $info->toString(1); This results in an XML document like this: <?xml version="1.0" encoding="UTF-8"?> <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"> <command> <info> <host:info xmlns:host="urn:ietf:params:xml:ns:host-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd"> <host:name>ns0.example-1.tldE<lt>/host:name> </host:info> </info> <clTRID>0cf1b8f7e14547d26f03b7641660c641d9e79f45</clTRIDE<gt> </command> </epp> OBJECT HIERARCHY
L<XML::LibXML::Node> +----L<XML::LibXML::Document> +----L<Net::EPP::Frame> +----L<Net::EPP::Frame::Command> +----L<Net::EPP::Frame::Command::Info> +----L<Net::EPP::Frame::Command::Info::Host> METHODS
$frame->setHost($host_name); This specifies the hostname for which information is being requested. AUTHOR
CentralNic Ltd (http://www.centralnic.com/). COPYRIGHT
This module is (c) 2012 CentralNic Ltd. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
o Net::EPP::Frame perl v5.14.2 2012-04-23 Net::EPP::Frame::Command::Info::Host(3pm)
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy