Sponsored Content
Top Forums Shell Programming and Scripting Count and print all repeating words in a line Post 302462052 by rdcwayx on Wednesday 13th of October 2010 05:32:41 AM
Old 10-13-2010
My code is similar as Scrutinizer's

Code:
awk '{delete a;s=0}{for (i=1;i<=NF;i++) if (++a[$i]==2) {printf $i FS;s++}}s{print s}' infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

count no of words in a line

hi i have a string like str=abc def ghi jkl now i want to count the no of words in the string please help (7 Replies)
Discussion started by: satish@123
7 Replies

2. Shell Programming and Scripting

print only last two words of a line

can u help me out to print last two words of each sentence of a file. for example. contents of input file: i love songs my favourite songs sent songs all kind good buddy Ouput file should contain: love songs favourite songs sent all kind good buddy (5 Replies)
Discussion started by: pradeepreddy
5 Replies

3. Shell Programming and Scripting

count no of words in a line

hi i have a line "abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc" I want to print the no of words, words separated by comma please help (3 Replies)
Discussion started by: Satyak
3 Replies

4. Shell Programming and Scripting

Count words on each line in file using xargs

Hi, im having a problem with xargs, i want to cout word of each line in file, and i HAVE to use xargs, i tried: cat file | xargs wc -w .....that uses all words in file like name of files and passed then to wc so it worte wc :somewordformfile is not i afile or directory cat file | xargs -I{} wc... (3 Replies)
Discussion started by: Qwetek
3 Replies

5. Shell Programming and Scripting

Print two matched words from the same line

Hi experts I need to pick 2 matched words from the same line..... I have given below an example file eg: O14757 hsa04110 hsa04115 2 P38398 hsa04120 1 O15111 hsa04010 hsa04210 hsa04920 hsa04620 hsa04660 hsa04662 hsa05200 hsa05212 hsa05221 hsa05220 hsa05215 hsa05222 hsa05120 13 O14920... (4 Replies)
Discussion started by: binnybio
4 Replies

6. Shell Programming and Scripting

How to print the words in the same line with space or to the predefined line?

HI, cat test abc echo "def" >> test output is cat test abc def the needed output is cat test abc def and so on (5 Replies)
Discussion started by: jobycxa
5 Replies

7. UNIX for Advanced & Expert Users

cut words based on the word count of a line

I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. https://www.unix.com/shell-programming-scripting/105841-count-words-each-line-file-using-xargs.html If the line has 6 words I would like to use this.... (8 Replies)
Discussion started by: cokedude
8 Replies

8. Shell Programming and Scripting

print number of words in each line

Hi, Please suggest a way to print number of words in the end of each line. <input file> red aunt house blue sky bat and ball game <output file> red aunt house 3 blue sky 2 bat and ball game 4 Thanks! (2 Replies)
Discussion started by: mira
2 Replies

9. Shell Programming and Scripting

Count and print the most repeating string in each line

Hi all, I have a file in which each string from column 1 is associated with one or multiple strings from column 2. For an example, in the sample input below, Gene1 from column1 is associated with two different strings from column 2 (BP1 and BP2).For every unique string from column 1, I need to... (9 Replies)
Discussion started by: AshwaniSharma09
9 Replies

10. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies
PMC.K7(3)						   BSD Library Functions Manual 						 PMC.K7(3)

NAME
pmc.k7 -- measurement events for AMD Athlon (K7 family) CPUs LIBRARY
Performance Counters Library (libpmc, -lpmc) SYNOPSIS
#include <pmc.h> DESCRIPTION
AMD K7 PMCs are present in the AMD Athlon series of CPUs and are documented in: AMD Athlon Processor x86 Code Optimization Guide, Publication No. 22007, Advanced Micro Devices, Inc., February 2002. PMC Features AMD K7 PMCs are 48 bits wide. Each K7 CPU contains 4 PMCs with the following capabilities: Capability Support PMC_CAP_CASCADE No PMC_CAP_EDGE Yes PMC_CAP_INTERRUPT Yes PMC_CAP_INVERT Yes PMC_CAP_READ Yes PMC_CAP_PRECISE No PMC_CAP_SYSTEM Yes PMC_CAP_TAGGING No PMC_CAP_THRESHOLD Yes PMC_CAP_USER Yes PMC_CAP_WRITE Yes Event Qualifiers Event specifiers for AMD K7 PMCs can have the following optional qualifiers: count=value Configure the counter to increment only if the number of configured events measured in a cycle is greater than or equal to value. edge Configure the counter to only count negated-to-asserted transitions of the conditions expressed by the other qualifiers. In other words, the counter will increment only once whenever a given condition becomes true, irrespective of the number of clocks during which the condition remains true. inv Invert the sense of comparison when the ``count'' qualifier is present, making the counter to increment when the number of events per cycle is less than the value specified by the ``count'' qualifier. os Configure the PMC to count events happening at privilege level 0. unitmask=mask This qualifier is used to further qualify a select few events, ``k7-dc-refills-from-l2'', ``k7-dc-refills-from-system'' and ``k7-dc-writebacks''. Here mask is a string of the following characters optionally separated by '+' characters: m Count operations for lines in the ``Modified'' state. o Count operations for lines in the ``Owner'' state. e Count operations for lines in the ``Exclusive'' state. s Count operations for lines in the ``Shared'' state. i Count operations for lines in the ``Invalid'' state. If no ``unitmask'' qualifier is specified, the default is to count events for caches lines in any of the above states. usr Configure the PMC to count events occurring at privilege levels 1, 2 or 3. If neither of the ``os'' or ``usr'' qualifiers were specified, the default is to enable both. AMD K7 Event Specifiers The event specifiers supported on AMD K7 PMCs are: k7-dc-accesses (Event 40H) Count data cache accesses. k7-dc-misses (Event 41H) Count data cache misses. k7-dc-refills-from-l2 [,unitmask=mask] (Event 42H) Count data cache refills from L2 cache. This event may be further qualified using the ``unitmask'' qualifier. k7-dc-refills-from-system [,unitmask=mask] (Event 43H) Count data cache refills from system memory. This event may be further qualified using the ``unitmask'' qualifier. k7-dc-writebacks [,unitmask=mask] (Event 44H) Count data cache writebacks. This event may be further qualified using the ``unitmask'' qualifier. k7-hardware-interrupts (Event CFH) Count the number of taken hardware interrupts. k7-ic-fetches (Event 80H) Count instruction cache fetches. k7-ic-misses (Event 81H) Count instruction cache misses. k7-interrupts-masked-cycles (Event CDH) Count the number of cycles when the processor's IF flag was zero. k7-interrupts-masked-while-pending-cycles (Event CEH) Count the number of cycles interrupts were masked while pending due to the processor's IF flag being zero. k7-l1-and-l2-dtlb-misses (Event 46H) Count L1 and L2 DTLB misses. k7-l1-dtlb-miss-and-l2-dtlb-hits (Event 45H) Count L1 DTLB misses and L2 DTLB hits. k7-l1-itlb-misses (Event 84H) Count L1 ITLB misses that are L2 ITLB hits. k7-l1-l2-itlb-misses (Event 85H) Count L1 (and L2) ITLB misses. k7-misaligned-references (Event 47H) Count misaligned data references. k7-retired-branches (Event C2H) Count all retired branches (conditional, unconditional, exceptions and interrupts). k7-retired-branches-mispredicted (Event C3H) Count all mispredicted retired branches. k7-retired-far-control-transfers (Event C6H) Count retired far control transfers. k7-retired-instructions (Event C0H) Count all retired instructions. k7-retired-ops (Event C1H) Count retired ops. k7-retired-resync-branches (Event C7H) Count retired resync branches (non control transfer branches). k7-retired-taken-branches (Event C4H) Count retired taken branches. k7-retired-taken-branches-mispredicted (Event C5H) Count mispredicted taken branches that were retired. Event Name Aliases The following table shows the mapping between the PMC-independent aliases supported by Performance Counters Library (libpmc, -lpmc) and the underlying hardware events used. Alias Event branches k7-retired-branches branch-mispredicts k7-retired-branches-mispredicted dc-misses k7-dc-misses ic-misses k7-ic-misses instructions k7-retired-instructions interrupts k7-hardware-interrupts unhalted-cycles (unsupported) SEE ALSO
pmc(3), pmc.atom(3), pmc.core(3), pmc.core2(3), pmc.iaf(3), pmc.k8(3), pmc.p4(3), pmc.p5(3), pmc.p6(3), pmc.soft(3), pmc.tsc(3), pmclog(3), hwpmc(4) HISTORY
The pmc library first appeared in FreeBSD 6.0. AUTHORS
The Performance Counters Library (libpmc, -lpmc) library was written by Joseph Koshy <jkoshy@FreeBSD.org>. BSD
October 4, 2008 BSD
All times are GMT -4. The time now is 06:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy