but I don't know how to say "the last record". I tried with NR but it didn't really help...
To know the last record, you have read the full input stream and then in the END pattern, print out the records. Since you are using an associative array in the mentioned manner, the elements of it will always contain the last records of any group.
And, setting OFS is useless in this case.
Code:
BEGIN{FS=";"}
{array[$1,$2]=$0}
END{for(a in array) print array[a]}
This User Gave Thanks to elixir_sinari For This Post:
Hi,
I'm trying this command - but get this error.
Do you guys have any workaround for this?
cat tf|sed 's/{//g'|sed 's/,//g'|awk '{for (i=1;i<=NF;i++) {if ($i == "OPTIME") {k = i + 2; print $i,$k}}}'
awk: record `2005 Jul 28 17:35:29...' has too many fields
record number 15
This is how... (3 Replies)
I have a file has following records
policy glb id 1233 name Permit ping from "One" to "Second" "Address1" "Any" "ICMP-ANY" permit
policy id 999251
service "snmp-udp"
exit
policy glb id 1234 name Permit telnet from "One" to "Second" "Address2" "Any" "TCP-ANY" permit
policy id 1234... (3 Replies)
Hi,
i want to generate print statement using awk.
i have 20+ and 30+ fields in each line
Now its priting only first eight fields print statement as output not all.
my record is as shown below filename
... (2 Replies)
Hi,
To be honest, I am really impressed and amazed at the pace I find solutions for un-solved coding mysteries in this forum.
I have a file like this
input1.txt
x y z 1 2 3
a b c 4 -3 7
k l m n 0 p
1 2 a b c 4
input2
x y z 9 0 -1
a b c 0 6 9
k l m 8 o p
1 2 a f x 9
Output... (9 Replies)
Dear All,
I have 2 files. If field 1, 2, 4 and 5 matches in both file1 and file2, I want to print the whole line of file1 and file2 one after another in my output file.
File1:
sc2/80 20 . A T 86 F=5;U=4
sc2/60 55 . G T ... (1 Reply)
I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Hi all , I have two files : dblp.xml with dblp records and itu1.txt with faculty members records. I need to find out how many dblp records are related to the faculty members. More specific: I need to find out which names from itu1.txt are a match in dblp. xml file , print them and show how many... (4 Replies)
Hi Everyone,
I have below record set. File is fixed widht file
101newjersyus 20150110
101nboston us 20150103
102boston us 20140106
102boston us 20140103
I need to group record based on first 3 letters in our case(101 and 102)
and sort last 8 digit in ascending order and print only... (4 Replies)
Hi,
My input looks like that:
A|123|qwer
A|456|tyui
A|456|wsxe
B|789|dfgh
Using awk, I am trying to get:
A|123;456|qwer;tyui;wsxe
B|789|dfgh
For records with same $1, group all the $2 in a field (without replicates), and all the $3 in a field (without replicates).
What I have tried:... (6 Replies)
Discussion started by: beca123456
6 Replies
LEARN ABOUT DEBIAN
lire::dlfstream
DlfStream(3pm) LogReport's Lire Documentation DlfStream(3pm)NAME
Lire::DlfStream - Interface to DLF data stream
SYNOPSIS
use Lire::DlfStore;
my $store = Lire::DlfStore->open( "mystore" );
my $dlf_stream = $store->open_dlf_stream( "www", "r" );
print "Data begins on ", scalar localtime $dlf_stream->start_time(), "
";
print "Data ends on ", scalar localtime $dlf_stream->end_time(), "
";
while ( my $dlf = $dlf_stream->read_dlf() ) {
...
}
DESCRIPTION
This object encapsulates DLF stream.
name
Returns the schema's name of the DlfStream.
mode()
Returns the mode in which the DlfStream was opened.
sort_spec()
Returns the sort specification that is set on the stream.
close()
This method should be called when the Lire::DlfStream isn't needed anymore, otherwise the same DlfStream cannot be opened until then.
nrecords()
Returs the number of DLF records in the stream.
start_time()
Returns the timestamp of the oldest DLF record in the stream in seconds since the epoch.
end_time()
Returns the timestamp of the newest DLF record in the stream in seconds since the epoch.
read_dlf()
Returns an hash reference containing the next DLF record in the stream. It returns undef once the end of the stream is reached.
This method will throw an exception if the DlfStream isn't open in 'r' mode or if there is an error reading the DLF record.
read_dlf_aref()
Returns the next DLF record in the stream as an array reference. The fields are in the order specified by the schema.
This method will throw an exception if the DlfStream isn't open in 'r' mode or if there is an error reading the DLF record.
write_dlf( $dlf, [ $link_ids ] )
Writes the fields contained in the hash ref $dlf to the DLF stream.
This method will throw an exception if there is an error writing the DLF record or if the stream isn't opened in 'w' mode.
The $link_ids parameter is used when the stream's schema is a Lire::DerivedSchema. It should be an array reference containing the DLF ids
of the records which are linked to this record.
clean( [ $time ] )
This method will remove all DLF records older than $time. It $time is omitted, all Dlf records will be removed.
Lire 2.1.1 2006-07-23 DlfStream(3pm)