Sponsored Content
Top Forums Programming String Manipulation in a text file Post 302763967 by neutronscott on Wednesday 30th of January 2013 05:59:10 PM
Old 01-30-2013
this may get you started?
Code:
mute@clt:~/temp/JohnTrevor$ cat script
#!/usr/bin/awk -f

$11 == "Request===>" && $13 == "openactive.assigned" { ass[$12]=$14 }
$11 == "Request===>" && $13 == "openactive.acknowledged" { ack[$12]=$14 }
$11 == "Request===>" && $13 == "openactive.analyzed" { anal[$12]=$14 }

END {
        for (tt in ass) {
                printf("[%s] ass:%d ack:%d analyse:%d\n", tt, ass[tt], ack[tt], anal[tt]);
        }
}
mute@clt:~/temp/JohnTrevor$ ./script log
[TT-000000052605] ass:1359431127 ack:1359431132 analyse:1359431135

This User Gave Thanks to neutronscott For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Text file manipulation

Hi, I need to remove lines from a text file that are less than certain length in UNIX. For example, test.txt file contains the following lines: abcdefghijklmnopqrstuvwxyz. 123456789009876543211234567 This line to be removed. zyxwvutsrqponmlkjihgfedcba. The length of each line is supposed... (5 Replies)
Discussion started by: svannala
5 Replies

2. UNIX for Dummies Questions & Answers

Text file manipulation

I am a new unix user & I wanted to work with unix as it is very good in text manipulations. I need a little help. I will be grateful if someone can help me out. I need help in grepping a pattern of numbers from one file to another file. Specific details are as follows: File one contains only... (4 Replies)
Discussion started by: Ezy
4 Replies

3. Shell Programming and Scripting

String manipulation in a file

I have a text file having number of different rows like this.. Action & Adventure|Whiteout| Kids Free|PBS KIDS Sprout|En espanol| Kids Free|PBS KIDS Sprout|En espanol|XYZ| Basically,i want to read the file and write to another file in a tree structure like this.. each row should have 6... (7 Replies)
Discussion started by: ramse8pc
7 Replies

4. Shell Programming and Scripting

File text manipulation

What I am trying to do is make a script that will add a port number within a section of a file if it already doesn't exist in that section of the file. The particular line that I would like to add the port number to in the file is formatted like this: TCPPORTS="25 80 125 443 8080 10000" For... (3 Replies)
Discussion started by: nullifx
3 Replies

5. Shell Programming and Scripting

Text File Manipulation

Hi, I need to write shell script for the scenario explained below - datafile.txt AcctNum,code,Region,,,, 12345451,AN ,abaab 12345452,AN ,xccxc 76677545,RP ,acxcc 43567878,RP ,afghh 32190900,AN ,afrfrf 87312345,AN ,aqaw I have a text file (datafile.txt)... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

6. UNIX for Dummies Questions & Answers

Text File Manipulation Help

Hi I've two text files FILE_1 and FILE_2 as shown below: FILE_1.txt CO Contig1 342 12 11 U GGGCTGACGTGGCCGCTAATACGACTCACTATAGGG*AGAGAAGTCATTTTCTTGTTTAG BQ 35 35 35 50 50 50 50 50 50 50 50 60 65 65 65 65 65 65 65 65 65 65 65 65 50 AF GP5UOVN01AOPE0 U 1 AF GP5UOVN01AT8W3 U 1 ... (1 Reply)
Discussion started by: Fahmida
1 Replies

7. Shell Programming and Scripting

Awk to convert a text file to CSV file with some string manipulation

Hi , I have a simple text file with contents as below: 12345678900 971,76 4234560890 22345678900 5971,72 5234560990 32345678900 71,12 6234560190 the new csv-file should be like: Column1;Column2;Column3;Column4;Column5 123456;78900;971,76;423456;0890... (9 Replies)
Discussion started by: FreddyDaKing
9 Replies

8. UNIX for Dummies Questions & Answers

Mathematical manipulation of a text file

I have a tab delimited file with 4 columns. If the value in the first column, equals the value in the second column, I'd like to have the 4th column multiplied by 2 then add 1. If the value in the first column differs from the value in the second, I'd like to have the 4th column multiplied by 2... (5 Replies)
Discussion started by: evelibertine
5 Replies

9. Shell Programming and Scripting

Text file manipulation

Hi Gurus, I have a question I have a flat file like below with three fields (3 rd field is amt) ad|B|500 cc||100 dd|C|600 ee||900 Need to write a code in such a way that when second field is empty then do sum of third field So in this case it will be 100 +900 I tried but no luck... (1 Reply)
Discussion started by: patricjemmy6
1 Replies

10. UNIX for Dummies Questions & Answers

Text File Manipulation

Hello, Supposing I had a huge list as follows: TAC manufacturer Device Type 1392600 LG D959 LG-D959TS FeaturePhone 1409700 LG V410 FeaturePhone 35150806 LG F350S FeaturePhone 35165206 Samsung GT-E1200 FeaturePhone 35194505 Nokia Asha 200 FeaturePhone but I want to make it look like... (3 Replies)
Discussion started by: Cludgie
3 Replies
IBV_GET_CQ_EVENT(3)					  Libibverbs Programmer's Manual				       IBV_GET_CQ_EVENT(3)

NAME
ibv_get_cq_event, ibv_ack_cq_events - get and acknowledge completion queue (CQ) events SYNOPSIS
#include <infiniband/verbs.h> int ibv_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq, void **cq_context); void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents); DESCRIPTION
ibv_get_cq_event() waits for the next completion event in the completion event channel channel. Fills the arguments cq with the CQ that got the event and cq_context with the CQ's context. ibv_ack_cq_events() acknowledges nevents events on the CQ cq. RETURN VALUE
ibv_get_cq_event() returns 0 on success, and -1 on error. ibv_ack_cq_events() returns no value. NOTES
All completion events that ibv_get_cq_event() returns must be acknowledged using ibv_ack_cq_events(). To avoid races, destroying a CQ will wait for all completion events to be acknowledged; this guarantees a one-to-one correspondence between acks and successful gets. Calling ibv_ack_cq_events() may be relatively expensive in the datapath, since it must take a mutex. Therefore it may be better to amor- tize this cost by keeping a count of the number of events needing acknowledgement and acking several completion events in one call to ibv_ack_cq_events(). EXAMPLES
The following code example demonstrates one possible way to work with completion events. It performs the following steps: Stage I: Preparation 1. Creates a CQ 2. Requests for notification upon a new (first) completion event Stage II: Completion Handling Routine 3. Wait for the completion event and ack it 4. Request for notification upon the next completion event 5. Empty the CQ Note that an extra event may be triggered without having a corresponding completion entry in the CQ. This occurs if a completion entry is added to the CQ between Step 4 and Step 5, and the CQ is then emptied (polled) in Step 5. cq = ibv_create_cq(ctx, 1, ev_ctx, channel, 0); if (!cq) { fprintf(stderr, "Failed to create CQ "); return 1; } /* Request notification before any completion can be created */ if (ibv_req_notify_cq(cq, 0)) { fprintf(stderr, "Couldn't request CQ notification "); return 1; } . . . /* Wait for the completion event */ if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) { fprintf(stderr, "Failed to get cq_event "); return 1; } /* Ack the event */ ibv_ack_cq_events(ev_cq, 1); /* Request notification upon the next completion event */ if (ibv_req_notify_cq(ev_cq, 0)) { fprintf(stderr, "Couldn't request CQ notification "); return 1; } /* Empty the CQ: poll all of the completions from the CQ (if any exist) */ do { ne = ibv_poll_cq(cq, 1, &wc); if (ne < 0) { fprintf(stderr, "Failed to poll completions from the CQ "); return 1; } /* there may be an extra event with no completion in the CQ */ if (ne == 0) continue; if (wc.status != IBV_WC_SUCCESS) { fprintf(stderr, "Completion with status 0x%x was found ", wc.status); return 1; } } while (ne); The following code example demonstrates one possible way to work with completion events in non-blocking mode. It performs the following steps: 1. Set the completion event channel to be non-blocked 2. Poll the channel until there it has a completion event 3. Get the completion event and ack it /* change the blocking mode of the completion channel */ flags = fcntl(channel->fd, F_GETFL); rc = fcntl(channel->fd, F_SETFL, flags | O_NONBLOCK); if (rc < 0) { fprintf(stderr, "Failed to change file descriptor of completion event channel "); return 1; } /* * poll the channel until it has an event and sleep ms_timeout * milliseconds between any iteration */ my_pollfd.fd = channel->fd; my_pollfd.events = POLLIN; my_pollfd.revents = 0; do { rc = poll(&my_pollfd, 1, ms_timeout); } while (rc == 0); if (rc < 0) { fprintf(stderr, "poll failed "); return 1; } ev_cq = cq; /* Wait for the completion event */ if (ibv_get_cq_event(channel, &ev_cq, &ev_ctx)) { fprintf(stderr, "Failed to get cq_event "); return 1; } /* Ack the event */ ibv_ack_cq_events(ev_cq, 1); SEE ALSO
ibv_create_comp_channel(3), ibv_create_cq(3), ibv_req_notify_cq(3), ibv_poll_cq(3) AUTHORS
Dotan Barak <dotanba@gmail.com> libibverbs 2006-10-31 IBV_GET_CQ_EVENT(3)
All times are GMT -4. The time now is 03:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy