for ENTRY in `grep -i group <file> | cut -f2 -d: | tr ',' '\012'`; do echo $ENTRY; done
replace "echo $ENTRY" by whatever suits ur needs, e.g.
ARRAY[$INDEX]=${ENTRY}
((INDEX=${INDEX}+1))
I have a small problem, Instead of text file, I have the text coming as an o/p of an other script i.e something similar to
but I don't see the same result as the original code. Please can you correct me?
I have a folder that contains say 50 files in a sequential order:
cdf_1.txt
cdf_2.txt
cdf_3.txt
cdf_3.txt
.
.
.
cdf_50.txt.
I need to merge these files in the same order into a single tab delimited file.
I used the following shell script:
for x in {1..50};
do cat cdf_${x}.txt >>... (3 Replies)
I have a file with the contents below
jan_t=jan;feb_t=feb;mar_t=mar;year=2010
jan_t=null;feb_t=feb;mar_t=mar;year=2010
jan_t=jan;feb_t=feb;mar_t=mar;year=2010
I want to extract out all the fields values ending with "_t" , however, i want to exclude feb_t and mar_t from the results
In... (6 Replies)
Hi,
I am having source (Oracle) as given below.
SourceOBJECT_NAMESUBOBJECT_NAMEOBJECT_IDDATA_OBJECT_IDOBJECT_TYPECREATEDLAST_DDL_TIMESTAMPSTATUSTGSTEST 336559336559TABLE4/15/2009 10:374/15/2009 10:372009-04-15:10:37:57VALIDNNNUNIX 336559336559TABLE4/15/2009 10:374/15/2009... (3 Replies)
Hi all,
I'm trying to get a bash script working for a program (bowtie) which takes a list of input files (*.fastq) and assembles them to an output file (outfile.sam). All the .fastq files are in one folder in my home directory (~/infiles).
The problem is that the 'bowtie' requires that... (7 Replies)
Hi All,
I need a unix script to convert .csv files to .skv files (changing a comma delimited file to a semi colon delimited file). I am a unix newbie and so don't know where to start. The script will be scheduled using cron and needs to convert each .csv file in a particular folder to a .skv... (4 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hi Guys,
I am new on the scripting world and would like ask for help if you can.
Here are my questions... (1 Reply)
Hi
I have the following file
# cat red
it.d-state = 50988 41498 45 0 0 0
it.age_buffer= 1500
it.dir = 1
I need to grep lines that are present after "="
But when I do so, few lines has more than one value and some has one
How to parse the line
I have used the follwing... (6 Replies)
Hi,
I am wanting to create a script that will construct a SQL statement based on a a space delimited string that it read from a config file.
Example of the SQL will be
For example, it will read a string like "AAA BBB CCC" and assign to a variable named IN_STRING.
I then concatenate... (2 Replies)
I have a large database with the following structure:
Indicword,Indicword,Indicword=English
on a line.
Not all lines will have this structure. Some might have a single word mapping to a single word in Indic.
An example will make this clear
... (4 Replies)
Discussion started by: gimley
4 Replies
LEARN ABOUT REDHAT
hsearch_r
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)