Sponsored Content
Full Discussion: awk problem
Special Forums UNIX Desktop Questions & Answers awk problem Post 302534828 by mrbinoy on Wednesday 29th of June 2011 12:06:33 AM
Old 06-29-2011
segregating data with awk

from employee table,need to segregate to their respective departments and to store in separate file,can any body help
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

AWK Problem

Hi, I posted something here about this yesterday but I can't seem to find it. I needed help writting a script which would append a file with new lines after every so many charachters. Example: (my original flat file) L60 LETTER OF CREDIT 60 DAYS W00 ON RECEIPT WIRE TRANSFER W30 NET... (12 Replies)
Discussion started by: gseyforth
12 Replies

2. Shell Programming and Scripting

Problem with AWK

Hi All, How can i store a value of the unix command executed in AWK with system command. devise=`cut -c1-3 dvgp.txt` I wrote this command in awk as awk'{ code= sprintf("devise=`cut -c1-3 dvgp.txt`"); system(code); }' Is this correct. can you please suggest me how the code can be... (1 Reply)
Discussion started by: krishna_gnv
1 Replies

3. Shell Programming and Scripting

problem using awk

Hi there every body I'm new to shell scripting and there is a problem facing me,, please look at the following piece of code: awk ' BEGIN{ FS="<assertion id=\1"; RS="<assertion id=\"2"}/<assertion id=\"1/{print FS$2 > "/home/ds2/test/output.txt"} ' filename all I wanna do is to... (6 Replies)
Discussion started by: senior_ahmed
6 Replies

4. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

5. Shell Programming and Scripting

Problem with awk awk: program limit exceeded: sprintf buffer size=1020

Hi I have many problems with a script. I have a script that formats a text file but always prints the same error when i try to execute it The code is that: { if (NF==17){ print $0 }else{ fields=NF; all=$0; while... (2 Replies)
Discussion started by: fate
2 Replies

6. Shell Programming and Scripting

awk problem

Find the number of files with sizes > 100KB in /, /bin, /usr, /usr/bin and /usr/sbin directories and output them in a two column format with the name of the directory and the number of files. i tried with awk $>ls -lh | awk '/^-/ && $5 >= 100k {print $8 $5}' but it is not working pls tell... (3 Replies)
Discussion started by: abhikamune
3 Replies

7. UNIX for Dummies Questions & Answers

Little problem with AWK

I thought I had solved this problem but after testing the script I came to realize that it is not doing what I need. So, here it goes again. This is the code: awk '/\>/{F=$2; N=$3; split(FILENAME, A, "."); getline; x = ">"}{print ">" A"-" x++" "F" " N"\n" $0}' This is the input file: ... (5 Replies)
Discussion started by: Xterra
5 Replies

8. Shell Programming and Scripting

awk problem - combining awk statements

i have a datafile that has several lines that look like this: 2,dataflow,Sun Mar 17 16:50:01 2013,1363539001,2990,excelsheet,660,mortar,660,4 using the following command: awk -F, '{$3=strftime("%a %b %d %T %Y,%s",$3)}1' OFS=, $DATAFILE | egrep -v "\-OLDISSUES," | ${AWK} "/${MONTH} ${DAY}... (7 Replies)
Discussion started by: SkySmart
7 Replies

9. Shell Programming and Scripting

awk problem

i have an email list in file.txt with comma separated line1 - FIELD1,pippo@gmail.com,darth@gmail.com line2 - FIELD2,pippo@gmail.com,darth@gmail.com,sampei@gmail.com output=(awk -F ',' -v var="$awkvar" '$1==var {print $2,$3,$4}' spreadsheet.txt)but awk delete some letters at the... (8 Replies)
Discussion started by: pasaico
8 Replies

10. Shell Programming and Scripting

awk problem

Hi I have two columns and I would like to create a third column based on how many lines away from a value of 1 in column 2, for example I have 1,0 2,0 3,0 4,0 5,0 6,1 7,0 8,0 9,0 10,0 11,1 And I want an output (6 Replies)
Discussion started by: garethsays
6 Replies
hsearch(3C)						   Standard C Library Functions 					       hsearch(3C)

NAME
hsearch, hcreate, hdestroy - manage hash search tables SYNOPSIS
#include <search.h> ENTRY *hsearch(ENTRY item, ACTION action); int hcreate(size_t mekments); void hdestroy(void); DESCRIPTION
The hsearch() function is a hash-table search routine generalized from Knuth (6.4) Algorithm D. It returns a pointer into a hash table indicating the location at which an entry can be found. The comparison function used by hsearch() is strcmp() (see string(3C)). The item argument is a structure of type ENTRY (defined in the <search.h> header) containing two pointers: item.key points to the comparison key, and item.data points to any other data to be associated with that key. (Pointers to types other than void should be cast to pointer-to- void.) The action argument is a member of an enumeration type ACTION (defined in <search.h>) indicating the disposition of the entry if it cannot be found in the table. ENTER indicates that the item should be inserted in the table at an appropriate point. Given a duplicate of an existing item, the new item is not entered and hsearch() returns a pointer to the existing item. FIND indicates that no entry should be made. Unsuccessful resolution is indicated by the return of a null pointer. The hcreate() function allocates sufficient space for the table, and must be called before hsearch() is used. The nel argument is an esti- mate of the maximum number of entries that the table will contain. This number may be adjusted upward by the algorithm in order to obtain certain mathematically favorable circumstances. The hdestroy() function destroys the search table, and may be followed by another call to hcreate(). RETURN VALUES
The hsearch() function returns a null pointer if either the action is FIND and the item could not be found or the action is ENTER and the table is full. The hcreate() function returns 0 if it cannot allocate sufficient space for the table. USAGE
The hsearch() and hcreate() functions use malloc(3C) to allocate space. Only one hash search table may be active at any given time. EXAMPLES
Example 1 Example to read in strings. The following example will read in strings followed by two numbers and store them in a hash table, discarding duplicates. It will then read in strings and find the matching entry in the hash table and print it. #include <stdio.h> #include <search.h> #include <string.h> #include <stdlib.h> struct info { /* this is the info stored in table */ int age, room; /* other than the key */ }; #define NUM_EMPL 5000 /* # of elements in search table */ main( ) { /* space to store strings */ char string_space[NUM_EMPL*20]; /* space to store employee info */ struct info info_space[NUM_EMPL]; /* next avail space in string_space */ char *str_ptr = string_space; /* next avail space in info_space */ struct info *info_ptr = info_space; ENTRY item, *found_item; /* name to look for in table */ char name_to_find[30]; int i = 0; /* create table */ (void) hcreate(NUM_EMPL); while (scanf("%s%d%d", str_ptr, &info_ptr->age, &info_ptr->room) != EOF && i++ < NUM_EMPL) { /* put info in structure, and structure in item */ item.key = str_ptr; item.data = (void *)info_ptr; str_ptr += strlen(str_ptr) + 1; info_ptr++; /* put item into table */ (void) hsearch(item, ENTER); } /* access table */ item.key = name_to_find; while (scanf("%s", item.key) != EOF) { if ((found_item = hsearch(item, FIND)) != NULL) { /* if item is in the table */ (void)printf("found %s, age = %d, room = %d ", found_item->key, ((struct info *)found_item->data)->age, ((struct info *)found_item->data)->room); } else { (void)printf("no such employee %s ", name_to_find) } } return 0; } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
bsearch(3C), lsearch(3C), malloc(3C), string(3C), tsearch(3C), malloc(3MALLOC), attributes(5), standards(5) The Art of Computer Programming, Volume 3, Sorting and Searching by Donald E. Knuth, published by Addison-Wesley Publishing Company, 1973. SunOS 5.11 29 Dec 1996 hsearch(3C)
All times are GMT -4. The time now is 08:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy