09-21-2010
Quote:
my $cnt=0;
while(<DATA>){
if(/>(.*)</){
push @arr, $1;
$cnt++;
}
if($cnt==3){
print $arr[2]," ",$arr[1],":",$arr[0],"\n";
$cnt=0;
@arr=();
}
}
__DATA__
<date>some_date</date>
<text>some_text</text>
<name>some_name<name>
<date>some_date</date>
<text>some_text</text>
<name>some_name<name>
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How can you tell how much a Solaris box is swapping? At what point do page in and page out become a problem? Here is a vmstat output.
> vmstat
procs memory page disk faults cpu
r b w swap free re mf pi po fr de sr m0 m1 m2 m3 in sy cs us sy id... (1 Reply)
Discussion started by: 98_1LE
1 Replies
2. SuSE
Hello!
Why does my SuSE GNU/Linux machine swap?
I have a Gig of ram, currently 14MBs of free RAM, 724MB - buffers and caches...
That is 685MB of cached RAM, then kernel really should'nt have to swap, It should release cached memory in my thinkin...
It has only swaped 3MB's but still,... (3 Replies)
Discussion started by: Esaia
3 Replies
3. Shell Programming and Scripting
I made a script that can swap info on two lines using a combination of awk and sed, but was hoping to consolidate the script to make it run faster. If found this script, but can't seem to get it to work in a bash shell. I keep getting the error "Too many {'s". Any help here would be appreciated:... (38 Replies)
Discussion started by: LaTortuga
38 Replies
4. Shell Programming and Scripting
I have a large file which reads like this:
fixed-address 192.168.6.6 {
hardware ethernet 00:22:64:5b:db:b1;
host X;
}
fixed-address 192.168.6.7 {
hardware ethernet 00:22:64:5b:db:b3;
host Y;
}
fixed-address 192.168.6.8 {
hardware ethernet 00:22:64:5b:db:b4;
host A;
}... (4 Replies)
Discussion started by: ksk
4 Replies
5. Shell Programming and Scripting
I'm a bit new to regex and sed/perl stuff, so I would like to ask for some advice. I have tried several variations of scripts I've found on the net, but can't seem to get them to work out just right.
I have a file with the following information...
# Host 1
host 45583 {
filename... (4 Replies)
Discussion started by: TheBigAmbulance
4 Replies
6. Shell Programming and Scripting
Hi All,
Sorry if this question has been posted elsewhere, but I'm hoping someone can help me! Bit of an AWK newbie here, but I'm learning (slowly!)
I'm trying to cobble a script together that will save me time (is there any other kind?), to swap two fields (one containing whitespace), with... (5 Replies)
Discussion started by: Bravestarr
5 Replies
7. Shell Programming and Scripting
Hallo Team,
This is the command that i am running :
grep ",Call Forward Not Reachable" *2013*
this is the output that i am getting (i did a head -10 but the files can be more than 1000)
... (8 Replies)
Discussion started by: kekanap
8 Replies
8. Shell Programming and Scripting
How can you swap the first 4 line only, the rest will stay the same.
thanks
#!/bin/sh
line=4
awk -v var="$line" 'NR==var {
s=$0
getline;s=$0"\n"s
getline;print;print s
next
}1' fileko.tx
.
desired output: (8 Replies)
Discussion started by: invinzin21
8 Replies
9. Solaris
Hi Guys
I am using SPARC-T4 (chipid 0, clock 2998 MHz), SunOS 5.10 Generic_150400-38 sun4v.
How do I see if the server was doing some swapping like yesterday?
I had a java application error with java.lang.OutOfMemoryError, now I want to check if the server was not doing some swapping at... (4 Replies)
Discussion started by: Phuti
4 Replies
10. Shell Programming and Scripting
Hi there,
I have a text that I'm trying to format into something more readable. However, I'm stuck in the last step. I've searched and tried things over the internet with no avail.
OS: Mac
After parsing the original text that I won't put here, I managed to get something like this, but this... (8 Replies)
Discussion started by: Kibou
8 Replies
LEARN ABOUT DEBIAN
pcap_dispatch
PCAP_LOOP(3PCAP) PCAP_LOOP(3PCAP)
NAME
pcap_loop, pcap_dispatch - process packets from a live capture or savefile
SYNOPSIS
#include <pcap/pcap.h>
typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h,
const u_char *bytes);
int pcap_loop(pcap_t *p, int cnt,
pcap_handler callback, u_char *user);
int pcap_dispatch(pcap_t *p, int cnt,
pcap_handler callback, u_char *user);
DESCRIPTION
pcap_loop() processes packets from a live capture or ``savefile'' until cnt packets are processed, the end of the ``savefile'' is reached
when reading from a ``savefile'', pcap_breakloop() is called, or an error occurs. It does not return when live read timeouts occur. A
value of -1 or 0 for cnt is equivalent to infinity, so that packets are processed until another ending condition occurs.
pcap_dispatch() processes packets from a live capture or ``savefile'' until cnt packets are processed, the end of the current bufferful of
packets is reached when doing a live capture, the end of the ``savefile'' is reached when reading from a ``savefile'', pcap_breakloop() is
called, or an error occurs. Thus, when doing a live capture, cnt is the maximum number of packets to process before returning, but is not
a minimum number; when reading a live capture, only one bufferful of packets is read at a time, so fewer than cnt packets may be processed.
A value of -1 or 0 for cnt causes all the packets received in one buffer to be processed when reading a live capture, and causes all the
packets in the file to be processed when reading a ``savefile''.
(In older versions of libpcap, the behavior when cnt was 0 was undefined; different platforms and devices behaved differently, so code that
must work with older versions of libpcap should use -1, nor 0, as the value of cnt.)
callback specifies a pcap_handler routine to be called with three arguments: a u_char pointer which is passed in the user argument to
pcap_loop() or pcap_dispatch(), a const struct pcap_pkthdr pointer pointing to the packet time stamp and lengths, and a const u_char
pointer to the first caplen (as given in the struct pcap_pkthdr a pointer to which is passed to the callback routine) bytes of data from
the packet. The struct pcap_pkthdr and the packet data are not to be freed by the callback routine, and are not guaranteed to be valid
after the callback routine returns; if the code needs them to be valid after the callback, it must make a copy of them.
RETURN VALUE
pcap_loop() returns 0 if cnt is exhausted, -1 if an error occurs, or -2 if the loop terminated due to a call to pcap_breakloop() before any
packets were processed. It does not return when live read timeouts occur; instead, it attempts to read more packets.
pcap_dispatch() returns the number of packets processed on success; this can be 0 if no packets were read from a live capture (if, for
example, they were discarded because they didn't pass the packet filter, or if, on platforms that support a read timeout that starts before
any packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode
and no packets were available to be read) or if no more packets are available in a ``savefile.'' It returns -1 if an error occurs or -2 if
the loop terminated due to a call to pcap_breakloop() before any packets were processed. If your application uses pcap_breakloop(), make
sure that you explicitly check for -1 and -2, rather than just checking for a return value < 0.
If -1 is returned, pcap_geterr() or pcap_perror() may be called with p as an argument to fetch or display the error text.
SEE ALSO
pcap(3PCAP), pcap_geterr(3PCAP), pcap_breakloop(3PCAP)
24 December 2008 PCAP_LOOP(3PCAP)