I am spooling a file from oracle and trying to delete the last line of the spooled file which I am unable to do.
Problem is that this file can have multiple records each time and I have no way of knowing how many because the amount can vary. I had an idea of using a while loop to read the... (1 Reply)
I am trying deleting lines from a text file using sed..
sed '/OBJECT="ABC/{N;N;N;d; }'
will do if i have to delete lines starting with Object and next 3 lines
but I was looking for a way to delet lines starting with OBJECT and all the lines till it reaches a blank lines ..or it reaches a... (8 Replies)
Hi
I have a file & always I need to remove or delete last 2 lines from that file. So in a file if I have 10 lines then it should return me first 8 lines.
Can someone help me? (4 Replies)
I have a file with 65 sets of 35 coordinates, and would like to isolate these coordinates so that I can easily copy the coordinates to another file. The problem is, I've got a 9 line header before each set of coordinates (so each set is 44 lines long). There are a zillion threads out there about... (3 Replies)
Hi All,
I am trying to extract lines bsed on pattern matching../mp straight-flow/
Extracted output should be saved in meta_string , but the code is not working in that manner,saving repeated lines. can anyone please suggest where am i going wrong.
/mp straight-flow/ {... (6 Replies)
I have a log file that I am processing. This contains messages from and to a server (requests and responses).
The responses to requests may not be in order i.e. we can have a response to a request after several requests are sent, and in some error cases there may not be any response message.
... (2 Replies)
hi all,
i have got a scenario in which i need to delete all the lines that ends with file names.
e.g.
input can be
cms/images/services_icons/callback.png
cms/cms/images/services_icons/sync.php
cms/cms/images/services_icons
and output should be
cms/cms/images/services_icons
... (13 Replies)
Hello, im using ex to manipulate some text. Im trying to delete all the lines except those on which a certain regex can be found.
the important part of the script:
ex temp << 'HERE'
g/regex/p
HERE
this command prints the lines I want to end up with, but it doesnt delete the others.... (2 Replies)
Hi All,
I want to write a script which first check the line counts of a file if its more than 500 it deletes rest except the last 500..
I tried sed but it looks sed counts line numbers from the head & not from tail.. May be I need a wc -l frist then apply if statement & pass on the line count... (17 Replies)
Say you want to clear your .bash_history except for the first 25 lines. Try:
sed -i -e 26,500d .bash_historyI have a some frequently-used routines parked in the first few lines, and they kept getting overwritten by more recent commands. (2 Replies)
Discussion started by: Xubuntu56
2 Replies
LEARN ABOUT REDHAT
hdestroy
HSEARCH(3) Linux Programmer's Manual HSEARCH(3)NAME
hcreate, hdestroy, hsearch - hash table management
SYNOPSIS
#include <search.h>
int hcreate(size_t nel);
ENTRY *hsearch(ENTRY item, ACTION action);
void hdestroy(void);
#define _GNU_SOURCE
#include <search.h>
int hcreate_r(size_t nel, struct hsearch_data *tab);
int *hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *tab);
void hdestroy_r(struct hsearch_data *tab);
DESCRIPTION
The three functions hcreate, hsearch, and hdestroy allow the user to create a hash table (only one at a time) which associates a key with
any data. The three functions hcreate_r, hsearch_r, hdestroy_r are reentrant versions that allow the use of more than one table.
First the table must be created with the function hcreate(). The argument nel is an estimate of the maximum number of entries in the ta-
ble. The function hcreate() may adjust this value upward to improve the performance of the resulting hash table.
The corresponding function hdestroy() frees the memory occupied by the hash table so that a new table can be constructed.
The argument item is of type ENTRY, which is a typedef defined in <search.h> and includes these elements:
typedef struct entry {
char *key;
void *data;
} ENTRY;
The field key points to the NUL-terminated string which is the search key. The field data points to the data associated with that key.
The function hsearch() searches the hash table for an item with the same key as item (where "the same" is determined using strcmp(3)), and
if successful returns a pointer to it. The argument action determines what hsearch() does after an unsuccessful search. A value of ENTER
instructs it to insert a copy of item, while a value of FIND means to return NULL.
RETURN VALUE
hcreate() and hcreate_r() return 0 when allocation of the memory for the hash table fails, nonzero otherwise.
hsearch() returns NULL if action is ENTER and the hash table is full, or action is FIND and item cannot be found in the hash table.
hsearch_r() returns 0 if action is ENTER and the hash table is full, and nonzero otherwise.
ERRORS
ENOMEM Out of memory.
CONFORMS TO
The functions hcreate, hsearch, and hdestroy are from SVID, and are described in POSIX 1003.1-2001. The functions hcreate_r, hsearch_r,
hdestroy_r are GNU extensions.
BUGS
SVID and POSIX 1003.1-2001 specify that action is significant only for unsuccessful searches, so that an ENTER should not do anything for a
successful search. The libc and glibc implementations update the data for the given key in this case.
Individual hash table entries can be added, but not deleted.
EXAMPLE
The following program inserts 24 items in to a hash table, then prints some of them.
#include <stdio.h>
#include <search.h>
char *data[] = { "alpha", "bravo", "charlie", "delta",
"echo", "foxtrot", "golf", "hotel", "india", "juliet",
"kilo", "lima", "mike", "november", "oscar", "papa",
"quebec", "romeo", "sierra", "tango", "uniform",
"victor", "whisky", "x-ray", "yankee", "zulu"
};
int main() {
ENTRY e, *ep;
int i;
/* starting with small table, and letting it grow does not work */
hcreate(30);
for (i = 0; i < 24; i++) {
e.key = data[i];
/* data is just an integer, instead of a
pointer to something */
e.data = (char *)i;
ep = hsearch(e, ENTER);
/* there should be no failures */
if (ep == NULL) {
fprintf(stderr, "entry failed
");
exit(1);
}
}
for (i = 22; i < 26; i++) {
/* print two entries from the table, and
show that two are not in the table */
e.key = data[i];
ep = hsearch(e, FIND);
printf("%9.9s -> %9.9s:%d
", e.key,
ep ? ep->key : "NULL",
ep ? (int)(ep->data) : 0);
}
return 0;
}
SEE ALSO bsearch(3), lsearch(3), tsearch(3), malloc(3)GNU 2001-12-26 HSEARCH(3)