Sponsored Content
Top Forums Shell Programming and Scripting Count and print all repeating words in a line Post 302462078 by danmero on Wednesday 13th of October 2010 07:24:52 AM
Old 10-13-2010
Quote:
Originally Posted by AshwaniSharma09
My need is, if a word repeats in a line get it printed. Also total number of repeats.
Code:
awk '{delete _;for(i=0;++i<=NF;){_[$i]++}}{for(i in _){if(_[i]-1){print i,_[i]}}}' file

 

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
XHPDeviceAutoRepeatOn(3X)												 XHPDeviceAutoRepeatOn(3X)

NAME
XHPDeviceAutoRepeatOn - Turn autorepeat on for an extension input device. XHPDeviceAutoRepeatOff - Turn autorepeat off for an extension input device. SYNOPSIS
int XHPDeviceAutoRepeatOn (display, deviceid, rate) Display *display; XID deviceid; unsigned int rate; int XHPDeviceAutoRepeatOff (display, deviceid) Display *display; XID deviceid; ARGUMENTS
display Specifies the connection to the X server. deviceid Specifies the ID of the desired device. rate Valid for XHPDeviceAutoRepeatOn only. Specifies the auto-repeat rate. Valid values are: REPEAT_30, which will cause repeats to take place every 1/30th second, and REPEAT_60, which will cause repeats to take place every 1/60th second. DESCRIPTION
These requests are part of an HP-proprietary extension to X. Their functionality has been superseded by the standard X input device extension XChangeFeedbackControl request. You should use XChangeFeedbackControl instead of XHPAutoRepeatOn and XHPAutoRepeatOff if possible. These requests are provided to support the use of input devices other than the X keyboard and X pointer device. They cannot be used to turn auto-repeat on or off for the X keyboard device. The core XAutoRepeatOn and XAutoRepeatOff requests should be used for that purpose. XHPDeviceAutoRepeatOn turns on or changes auto-repeat for an extended input device that is attached to the specified display. XHPDeviceAutoRepeatOff turns off autorepeat for an extended input device that is attached to the specified display. RETURN VALUE
none DIAGNOSTICS
Either request can return a BadDevice error. XHPDeviceAutoRepeatOn can return a BadValue error. BadDevice An invalid device ID was specified. BadValue An invalid rate was specified. FILES
/usr/include/X11/XHPlib.h ORIGIN
Hewlett-Packard Company SEE ALSO
XAutoRepeatOn(3x) XAutoRepeatOff(3x) X Version 11 Release 5 XHPDeviceAutoRepeatOn(3X)
All times are GMT -4. The time now is 07:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy