Sponsored Content
Top Forums Shell Programming and Scripting Counting non-specific occurrences within a file. Post 302732689 by hergp on Monday 19th of November 2012 03:23:16 AM
Old 11-19-2012
One way would be to use uniq

Code:
$ cat in
horse
sheep
cow
sheep
sheep
cow
$ sort in | uniq -c
      2 cow
      1 horse
      3 sheep

But that only works, if the file is not too big to sort.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting occurences of specific charachter in a file

Hi, I need to count the number of occurences of the character " in a file that contains huge number of records. What command could I use? Please specify in detail since I am new :| Thanks much. (3 Replies)
Discussion started by: GMMike
3 Replies

2. Shell Programming and Scripting

Counting the differences based on a specific rule

Hi, I've been trying to create a perl file to run something very specific. But I'm not getting any success. I'm not very good with hashing. I have a file with two columns (tab separated) (already sorted) 99890 + 100281 + 104919 - 109672 + 113428 - 114501 + 115357 + 115598 ... (7 Replies)
Discussion started by: labrazil
7 Replies

3. Shell Programming and Scripting

counting number of pattern occurrences

Hi All, Is it possible to count number of occurrences of a pattern in a single record using awk?? for example: a line like this: abrsjdfhafa I want to count the number of a character occurrences. but still use the default RS, I don't want to set RS to single character. (1 Reply)
Discussion started by: ghoda2_10
1 Replies

4. Shell Programming and Scripting

Counting specific words from the log

Hi, I need a shell script which can provide details from error logs like this Aug 23 21:19:41 red mountd: authenticated mount request from bl0110.bang.m pc.local:651 for /disk1/jobs (/disk1) Aug 23 08:49:52 red dhcpd: DHCPDISCOVER from 00:25:90:2b:cd:7c via eth0: unknown client Aug 24... (2 Replies)
Discussion started by: ratheeshp
2 Replies

5. Shell Programming and Scripting

Counting occurrences of all words in multiple files

Hey Unix gurus, I would like to count the number occurrences of all the words (regardless of case) across multiple files, preferably outputting them in descending order of occurrence. This is well beyond my paltry shell scripting ability. Researching, I can find many scripts/commands that... (4 Replies)
Discussion started by: twjolson
4 Replies

6. Shell Programming and Scripting

How to count occurrences in a specific column

Hi, I need help to count the number of occurrences in $3 of file1.txt. I only know how to count by checking one by one and the code is like this: awk '$3 ~ /aku hanya poyo/ {++c} END {print c}' FS="\t" file1.txt But this is not wise to do as i have hundreds of different occurrences in that... (10 Replies)
Discussion started by: redse171
10 Replies

7. Shell Programming and Scripting

[Solved] Counting specific characters within each field

Hello, I have a file like following: ALB_13554 1 1 1 ALB_13554 1 2 1 ALB_18544 2 0 2 ALB_18544 1 0 1 This is a sample of my file, my real file has 441845 number of fields. What I want to do is to calculate the number of 1 and 2 in each column using AWK, so, the output file looks like... (5 Replies)
Discussion started by: Homa
5 Replies

8. UNIX for Dummies Questions & Answers

BASH - Counting word occurrences in a Web Page

Hi all, I have to do a script bash (for university) that counts all word occurrences in a specific web page. anyone can help me?. Thanks :) (1 Reply)
Discussion started by: piacentero
1 Replies

9. UNIX for Dummies Questions & Answers

Awk: Counting occurrences between two files

Hi, I have two text files (1.txt and 2.txt). 2.txt contains two columns which are extracted from 1.txt using a simple if(condition) print. I want to: - count how many times the values contained in 2.txt appear in 1.txt -if they appear just one time, I have to delete the entire row in... (5 Replies)
Discussion started by: Pintug
5 Replies

10. Shell Programming and Scripting

Counting specific column and add result in output

Hi all, I have a quick question: I have a 4 column tab-separated file. I want to count the number of times each unique value in column 2 appears and add that number in a 5th column. I have the following input file: waterline-n below-sheath-v 14.8097 A dock-n below-sheath-v ... (4 Replies)
Discussion started by: owwow14
4 Replies
xcowsay(6)							   Games Manual 							xcowsay(6)

NAME
xcowsay - Display a cute cow and speech bubble. SYNOPSIS
xcowsay [-h] [-t time] [-r speed] [-d] [-f font] [text]... DESCRIPTION
Display a cow with a speech bubble containing some text. If text is specified it will be displayed in the bubble. Otherwise the text will be read from the standard input and displayed when end of file is encountered. The cow is displayed for either a fixed amount of time, or an amount of time calculated from the size of the text. Click on the cow to dis- miss it immediately. If xcowsay is started with --daemon it will fork away from the terminal and run in daemon mode. The daemon provides a DBus service uk.me.doof.Cowsay that responds to ShowCow requests. The daemon can queue up any number of requests and displays them in order. When xcowsay starts it checks to see if a daemon is running, and if it is, sends a ShowCow request and returns immediately. Otherwise xcowsay will block until the cow has disappeared. CONFIGURATION FILE
xcowsay reads a configuration file on startup. The configuration file can be stored in the XDG compliant location $XDG_CON- FIG_HOME/xcowsayrc (which will default to $HOME/.config/xcowsayrc) or in your home directory at $HOME/.xcowsayrc. If the --config=FILE command line option is passed FILE will be processed after your personal configuration file. The configuration file consists of 'option = value' pairs, one per line. The valid keys are given in the next section. For example, the following line sets display time to 10 seconds: display_time = 10000 The character '#' begins a comment which lasts until the end of the line. OPTIONS
Note that these options override any settings in the config file. -h, --help Display usage information. -t time, --time=time Display the cow for time seconds. This overrides any value set for reading_speed. The corresponding config file option is dis- play_time. -r speed, --reading-speed=speed Number of milliseconds to display the cow for each word in the input text. This is clamped to a minimum of min_display_time and a maximum of max_display_time. The defaults are 1 second and 30 seconds respectively. The corresponding config file option is read- ing_speed. -f font, --font=font Font for the speech bubble text. Accepts Pango font strings. The corresponding config file option is font. -d file, --dream=file Display an image instead of text in the cow's bubble. The dream_time config file option sets the numer of milliseconds to display the image for. The default is 10 seconds. --think Display a thought bubble instead of a speech bubble. --daemon Run xcowsay in daemon mode if DBus support has been enabled. See the description for more information. --cow-size=size Size of the cow image. Current choices are small, med, or large. The corresponding config file option is cow_size. --image=file Use a different image instead of the cow. The corresponding config file option is alt_image. --monitor=N Make the cow appear on monitor N. --at=X,Y Force that cow to appear at screen location (X,Y). The config file options are at_x and at_y. --bubble-at=X,Y Change position of bubble relative to where it would normally appear. This is most useful when combined with the alt_image option to create your own characters. The config file options are bubble_x and bubble_y. --debug Print messages about what xcowsay is doing. Useful for finding out why the daemon fails. -v, --version Print version information. AUTHOR
Written by Nick Gasson. REPORTING BUGS
Report all bugs to nick@nickg.me.uk The xcowsay home page is <http://www.doof.me.uk/xcowsay> SEE ALSO
cowsay(6) BUGS
There are a few issues I am aware of: The cow and speech bubble have jagged edges which would be improved by anti-aliasing. Very long strings will disappear off the right-hand side of the screen. This could be fixed e.g. by using Pango's word wrapping. xcowsay(6)
All times are GMT -4. The time now is 03:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy