Sponsored Content
Top Forums Shell Programming and Scripting Match and count the number of times Post 302424113 by durden_tyler on Monday 24th of May 2010 08:37:03 AM
Old 05-24-2010
Code:
$
$
$ cat file1
Beckham
Ronaldo
$
$ cat file2
Beckham Beckham_human
Ronaldo Ronaldo_spain
Ronaldo Ronaldo_brazil
Beckham Beckham_manch
Zidane Zidane_Fran
Rooney Rooney_Eng
$
$
$ perl -lane 'chomp; if ($ARGV eq "file1"){$x{$F[0]}=1} elsif (defined $x{$F[0]}){$y{$F[0]}++}
              END {foreach $k(keys %y){print "$k => $y{$k}"}}' file1 file2
Beckham => 2
Ronaldo => 2
$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

count times for one string

I have a file. I want to count the time for one string appears in this file Example: 56 73 34 79 90 56 34 Expected results 2:56 1:73 2:34 (1 Reply)
Discussion started by: anhtt
1 Replies

2. Shell Programming and Scripting

scripting - write a script that will count the number of times a particular word

hello everyone, I'm trying to learn some scripts but i cant get my head around two of them. 1. how can i write a script that will count the number of times a particular word is used in file? 2. how can i make a script that will take me to a web page from unix? if anyone could help it... (3 Replies)
Discussion started by: BigTool4u2
3 Replies

3. UNIX for Dummies Questions & Answers

Comparing two files and count number of lines that match

Hello all, I always found help for my problems using the search option, but this time my request is too specific. I have two files that I want to compare. File1 is the index and File2 contains the data: File1: chr1 protein_coding exon 500 600 . + . gene_id "20532";... (0 Replies)
Discussion started by: DerSeb
0 Replies

4. Shell Programming and Scripting

The loop was executed $count times

#!/bin/sh count=0 for i in 2 4 6 do echo "i is $i" count='expr $count + 1' done echo "The loop was executed $count times" with these scripts my output is : i is 2 i is 4 i is 6 The loop was executed expr $count + 1 times What should I do to get the value instead of 'expr... (17 Replies)
Discussion started by: ymwong
17 Replies

5. UNIX for Dummies Questions & Answers

how to count number of times each word exist in a file

I'm trying to count the number of times each word in the file exist for example if the file has: today I have a lot to write, but I will not go for it. The main thing is that today I am looking for a way to get each word in this file with a word count after it specifying that this word has... (4 Replies)
Discussion started by: shnkool
4 Replies

6. Shell Programming and Scripting

Count number of match words

Input: some random text SELECT TABLE1 some more random text some random text SELECT TABLE2 some more random text some random text SELECT TABLE3 some more random text some random text SELECT TABLE1 some more random text Output: 'SELECT TABLE1' 2 'SELECT TABLE2' 1 'SELECT TABLE3' 1 I... (5 Replies)
Discussion started by: chitech
5 Replies

7. Shell Programming and Scripting

Count how many times in every file, strings appeared in a directory.

Hello, I have some files and i want to count how many times a string is appeared in each file. Lets say : #cat fileA stringA sdh stringB stringA #cat fileB stringB stringA sdb stringB stringB I need the output to be something like: (2 Replies)
Discussion started by: @dagio
2 Replies

8. UNIX for Dummies Questions & Answers

How do I count how many times a specific word appear in a file (ksh)?

Hi Please can you help how do I count the number of specific characters or words that appear in a file? (8 Replies)
Discussion started by: fretagi
8 Replies

9. Shell Programming and Scripting

Count same word which has come many times in single lines & pars

can i get a simple script for , Count same word which has come many times in single lines & pars Eg file would be == "Thanks heman thanks thanks Thanks heman thanks man" So resullt should be Thanks = 5 heman=2 man = 1 thanks in advance :) Please use code tags for code and... (1 Reply)
Discussion started by: heman96
1 Replies

10. UNIX for Beginners Questions & Answers

Count the number of files to delete doesnt match

Good evening, need your help please Need to delete certain files before octobre 1 2016, so need to know how many files im going to delete, for instance ls -lrt file_20160*.lis!wc -l but using grep -c to another file called bplist which contains the list of all files backed up doesn match... (7 Replies)
Discussion started by: alexcol
7 Replies
OSDClock(1)						      General Commands Manual						       OSDClock(1)

NAME
osd_clock - X on-screen clock displayer SYNOPSIS
osd_clock [OPTION]... [+FORMAT] DESCRIPTION
Display date/time information on screen. -f FONT Set font. -c COLOR Set color. -d DELAY Sets the delay (in seconds) that the clock is exposed. Useful if combined with INTERVAL. -F FORMAT This option specifies the format to be used to output the date. See 'strftime(3)'. -i INTERVAL This specifies the interval between displays. Default is 1 (display every second). -H INTEGER The "chimes per hour" count overrides -i. Default is 0 (no effect). The time will be displayed this many times each hour (notwithstanding signals interrupting sleep, and leap seconds). The first dis- play of the hour will be on the hour exactly. Use -H 4 for a display at 0, 15, 30 and 45 minutes past. -s SHADOW This option sets the shadow depth. Default 2. -t locate clock at top left (default: bottom left). -b locate clock at bottom left (default). -o OFFSET This option specifies the offset from the top or bottom of screen the text is displayed. The default is 0. Useful to move above or below panels or applets. -h, --help display this help and exit BUGS
The per-hour mode may fire up to one second late, or worse if the system is busy. AUTHOR
Jon Beckham <leftorium@leftorium.net> Martijn van de Streek <martijn@foodfight.org> Nathan Walp <faceprint@faceprint.com> COPYRIGHT
It is distributed under the GNU General Public License. X OSD Clock March 2001 OSDClock(1)
All times are GMT -4. The time now is 02:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy