Sponsored Content
Full Discussion: Add number of occurence
Top Forums UNIX for Dummies Questions & Answers Add number of occurence Post 302955274 by RavinderSingh13 on Wednesday 16th of September 2015 02:17:04 AM
Old 09-16-2015
Hello radius,

Following may help you in same.
Code:
awk -F"|" '{A[$1 FS $5]++;print $0 FS A[$1 FS $5]}' Input_file

Output will be as follows.
Code:
81161267334|1|100000|81329998077|20150902|1
81161267334|1|50000|82236060161|20150902|2
81161268637|1|25000|81329012229|20150911|1
81161269307|1|25000|81327019134|20150901|1
81161269307|1|25000|81328309109|20150905|1
81161269307|1|25000|85239333736|20150908|1
81161269307|1|100000|81313991122|20150913|1
81161414275|1|50000|82187797112|20150903|1
81161414275|1|50000|82187797112|20150903|2
81161414275|1|50000|82238727677|20150903|3
81161414275|1|25000|82358092103|20150904|1
81161414275|1|50000|82187206169|20150905|1
81161414275|1|50000|82238727677|20150905|2
81161414275|1|25000|81241183717|20150905|3
81161414275|1|25000|81340850588|20150905|4
81161414275|1|50000|81354897982|20150908|1
81161414275|1|100000|82292121045|20150911|1
81161414275|1|50000|81342631555|20150912|1
81161416856|1|50000|81241282054|20150912|1
81161447387|1|50000|82192141007|20150901|1
81161447387|1|50000|85333777497|20150901|2
81161447387|1|50000|81241633253|20150902|1
81161447387|1|50000|82292161069|20150903|1
81161447387|1|25000|85397300602|20150905|1
81161447387|1|50000|82191911002|20150906|1
81161447387|1|25000|85256849437|20150906|2
81161447387|1|25000|85222222506|20150907|1
81161447387|1|50000|85325354000|20150908|1
81161447387|1|50000|82292161069|20150909|1
81161447387|1|50000|82348480606|20150911|1
81161447387|1|25000|82187158088|20150912|1
81161447387|1|25000|82346462000|20150913|1
81161455642|1|100000|81331425198|20150901|1

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count the number of occurence of perticular word from file

I want to count the number of occurence of perticular word from one text file. Please tell me "less" command is work in ksh or not. If it is not working then instead of that which command will work. :confused: (40 Replies)
Discussion started by: rinku
40 Replies

2. Shell Programming and Scripting

first occurence and line number

Hi, My objective is to get the line number of the first occurance of the search pattern. my test.txt contains: ..... .................. total rows.... ................... .. total rejected rows: 40 total rejected rows: 50 total rejected rows: 80 total rejected rows: 90 total... (9 Replies)
Discussion started by: mercuryshipzz
9 Replies

3. UNIX for Dummies Questions & Answers

grep the number of first occurence

File1.txt ....... ....... OMC LA OMC LK OMC LS ........ ........ Above is the content of File1.txt, i want to get the Number of Occurence to order, lets say if OMC LA = 1, OMC LS=3, and OMC LK=2.. omc_ident="OMC LA" or "OMC LK" or "OMC LS" omc_num=`grep '^OMC' File1.txt| grep... (4 Replies)
Discussion started by: neruppu
4 Replies

4. UNIX for Dummies Questions & Answers

number of occurence using grep -c then assigning it to a variable

Hi guys! I need to count the occurence of a certain pattern. For example the pattern is PC. the contents of the file sample.txt: A PC asdfgadfjkl asdfa PC sadfaf fdsPCasdfg if i use grep -c PC sample.txt it will display 3 as the number of occurence how do i save that number to a... (1 Reply)
Discussion started by: khestoi
1 Replies

5. Shell Programming and Scripting

finding the number of occurence of a word in a line

suppose i have this line abs|der|gt|dftnrk|dtre i want to count the number of "|" in this line.. how can i do that. plz help:confused: (9 Replies)
Discussion started by: priyanka3006
9 Replies

6. Shell Programming and Scripting

Number each occurence using sed

hi, I need to number each occurrence of a pattern within a file using sed. Given object 0000 object 111 object 222 I need following 1.object 0000 2.object 111 3.object 222 (5 Replies)
Discussion started by: xerox
5 Replies

7. Shell Programming and Scripting

Count number of character occurence but not from quotation marks

I have the following string: 31-01-2012, 09:42:37;OK;94727132638;"Mozilla/5.0 (Linux; U; Android 2.2.1)";3G;WAP;I need a script which is counting the occurrence of semicolons ( ; ) but exclude the ones from the quotation marks. In the string given as example there are 8 semicolons but the script... (3 Replies)
Discussion started by: calinlicj
3 Replies

8. Shell Programming and Scripting

Split column into two on first occurence of any number

Input : abc def 1 xyz zzz bca cde 2 yyy xxx Expected output : abc def |1 xyz zzz bca cde |2 yyy xxx I have tried the command below and losing the number. Any help is greatly appreciated 1. sed 's//|/' num.txt Result: abc def | xyz zzz bca cde |... (7 Replies)
Discussion started by: kbsuryadev
7 Replies

9. Programming

Python Count Number Of Occurence

Hello, I have a programming assignment to count number of occurrences of hours in particular file. Below is the code: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" largest = None fh = open(fname) counts = dict() test = list() for line in fh: ... (2 Replies)
Discussion started by: infinitydon
2 Replies

10. Shell Programming and Scripting

Print occurence number

Hi folks, I have a file with lots of lines in a text file,i need to print the occurence number after sorting based on the first column as shown below, thanks in advance. sam,dallas,20174 sam,houston,20175 sam,atlanta,20176 jack,raleigh,457865 jack,dc,7845 john,sacramento,4567 ... (4 Replies)
Discussion started by: tech_frk
4 Replies
INSTR(3)						       MBK UTILITY FUNCTIONS							  INSTR(3)

NAME
instr - find an occurence of a string in a string, starting at a specified character. ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr SYNOPSYS
#include "mut.h" char *instr(s, find, from) char *s, *find, from; PARAMETERS
s Pointer to the string to be searched for the pattern find Pointer to the string to be found, the pattern from Character to be searched backwards before searching for the pattern DESCRIPTION
instr searches the first occurence of the string find in the string s, starting its search at the last occurence of the from character in the string s. If either s or find is NULL, the function returns NULL. If from is (char)0, the pattern is searched from the begining of s. This quite exotic behaviour is useful to search the occurence of a name in a string resulting from a flatten, when only a terminal object name is to be taken into account. RETURN VALUES
instr return NULL either if the pattern find is not present in the searched string s, or if one at least of these two string are NULL. If the pattern is found, a value different from NULL is returned. EXAMPLE
#include "mut.h" /* check for the pattern 'ck' anywhere in the string */ #define contains_ck(name)instr(name, "ck", ' ') /* check for the pattern 'ck' in the signal name, not instance ones */ #define isclock(ptsig) instr(getsigname(ptsig), "ck", SEPAR) SEE ALSO
mbk(1), isvdd(3), isvss(3). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 October 1, 1997 INSTR(3)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy