Sponsored Content
Top Forums Shell Programming and Scripting grouping records in a file in unix Post 302352085 by girish1428 on Thursday 10th of September 2009 10:52:13 AM
Old 09-10-2009
I havent run the following, but I think it will work...


Code:
for i in `cat file | cut -d"," -f1`
do
grep $i file >> temp
head -1 temp >> result
count_line=`wc -l temp`
count=`echo $count_line | tr -s " " " " |cut -d" " -f1`
if [ $count -gt 1 ]
then
count=` expr $count - 1 `
tail -$count temp | cut -c6- >> result
fi
rm temp
done


Last edited by girish1428; 09-10-2009 at 12:23 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grouping and summing data through unix

Hi everyone, I need a help on Unix scripting. I have a file is like this Date Amt 20071205 10 20071204 10 20071203 200 20071204 300 20071203 400 20071205 140 20071203 100 20071205 100... (1 Reply)
Discussion started by: pcharanraj
1 Replies

2. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

3. Shell Programming and Scripting

File splitting and grouping using unix script

Hello All, I have a small problem with file group/splitting and I am trying to get the best way to perform this in unix. I am trying with awk but need some suggestion what would be the best and fastest way to-do it. Here is the problem. I have a fixed length file with filled with product... (4 Replies)
Discussion started by: nandhan11891
4 Replies

4. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

5. Shell Programming and Scripting

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (1 Reply)
Discussion started by: mkandula1983
1 Replies

6. UNIX for Dummies Questions & Answers

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (6 Replies)
Discussion started by: mkandula1983
6 Replies

7. Shell Programming and Scripting

Extract records from Oracle to UNIX file with headers

Hi, I have a shell script which extracts records form oracle to unix file. sqlplus -s ${WMD_DM_CONNECT} <<EOF >$tmpfile set heading off set pagesize 0 set feedback off select CD_DESC||'|'||CD_ID||'|'||'Arun'||'|'||'Montu' from WMD_SYS_CD_LKUP where CD_TYP =... (5 Replies)
Discussion started by: Arun Mishra
5 Replies

8. Windows & DOS: Issues & Discussions

How to copy a file with long records ,i.e spanning to 2 or 3 lines from UNIX to excel?

Hi Experts, I have a Unix csv file which has long records ie the record length is more than 80 so it goes to the next line.So when its in unix though it spans to two or three lines it still counts it as one record. But what is happening is for the records that are long when i copy it into excel i... (0 Replies)
Discussion started by: 100bees
0 Replies

9. Shell Programming and Scripting

UNIX grouping

Hi guys, I am a complete newbie to unix and have been tasked with creating a script to group the following data (file) by hourly slots so that I can count the transactions completed within the peak hour. I am not sure how to group data like this in unix. Can anyone please help? Here is an... (1 Reply)
Discussion started by: MrMidas
1 Replies

10. Shell Programming and Scripting

To group records in the file in UNIX

Hi All, I am using RHEL 6.9. I got a requirement to group the records in a file.The file content as shown below. #### FAILED JOBS IN XXX ##### 1> ABCD failed in the project XXX 2> HJK Job is in compiled state in the project XXX 3> ILKD failed in the project XXX 4> DFG failed in the... (5 Replies)
Discussion started by: ginrkf
5 Replies
d2i_SSL_SESSION(3)						      OpenSSL							d2i_SSL_SESSION(3)

NAME
d2i_SSL_SESSION, i2d_SSL_SESSION - convert SSL_SESSION object from/to ASN1 representation LIBRARY
libcrypto, -lcrypto SYNOPSIS
#include <openssl/ssl.h> SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length); int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); DESCRIPTION
d2i_SSL_SESSION() transforms the external ASN1 representation of an SSL/TLS session, stored as binary data at location pp with length length, into an SSL_SESSION object. i2d_SSL_SESSION() transforms the SSL_SESSION object in into the ASN1 representation and stores it into the memory location pointed to by pp. The length of the resulting ASN1 representation is returned. If pp is the NULL pointer, only the length is calculated and returned. NOTES
The SSL_SESSION object is built from several malloc()ed parts, it can therefore not be moved, copied or stored directly. In order to store session data on disk or into a database, it must be transformed into a binary ASN1 representation. When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically allocated. The reference count is 1, so that the session must be explicitly removed using SSL_SESSION_free(3), unless the SSL_SESSION object is completely taken over, when being called inside the get_session_cb() (see SSL_CTX_sess_set_get_cb(3)). SSL_SESSION objects keep internal link information about the session cache list, when being inserted into one SSL_CTX object's session cache. One SSL_SESSION object, regardless of its reference count, must therefore only be used with one SSL_CTX object (and the SSL objects created from this SSL_CTX object). When using i2d_SSL_SESSION(), the memory location pointed to by pp must be large enough to hold the binary representation of the session. There is no known limit on the size of the created ASN1 representation, so the necessary amount of space should be obtained by first calling i2d_SSL_SESSION() with pp=NULL, and obtain the size needed, then allocate the memory and call i2d_SSL_SESSION() again. Note that this will advance the value contained in *pp so it is necessary to save a copy of the original allocation. For example: int i,j; char *p, *temp; i = i2d_SSL_SESSION(sess, NULL); p = temp = malloc(i); j = i2d_SSL_SESSION(sess, &temp); assert(i == j); assert(p+i == temp); RETURN VALUES
d2i_SSL_SESSION() returns a pointer to the newly allocated SSL_SESSION object. In case of failure the NULL-pointer is returned and the error message can be retrieved from the error stack. i2d_SSL_SESSION() returns the size of the ASN1 representation in bytes. When the session is not valid, 0 is returned and no operation is performed. SEE ALSO
ssl(3), SSL_SESSION_free(3), SSL_CTX_sess_set_get_cb(3) 1.0.1i 2014-08-10 d2i_SSL_SESSION(3)
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy