Sponsored Content
Top Forums Shell Programming and Scripting Counting Instances of a String with AWK Post 302704847 by Pjstaab on Sunday 23rd of September 2012 06:36:01 PM
Old 09-23-2012
Counting Instances of a String with AWK

I have a list of URLs and I want to be able to count the number of instances of addresses ending in a certain TLD and output and sort it like so.

5 bdcc.com
48 zrtzr.com
49 rvo.com

Input is as so
Code:
ync.org
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
sduzj.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
hmeyy.edu
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
zrtzr.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
rvo.com
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
mnw.edu
bdcc.com
bdcc.com
bdcc.com
bdcc.com
bdcc.com
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu
dhkys.edu

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Counting the max length of string

Hi all, I have a flat file of 1000 rows. I want to check the length of the 5th column. The one having the longest length , I want to set it as DEFINED PARAMETER. So later I can check others with that particular number only. Any ideas ?? (2 Replies)
Discussion started by: ganesh123
2 Replies

2. Shell Programming and Scripting

How to replace all string instances found by find+grep

Hello all Im performing find + grep operation that looks like this : find . -name "*.dsp" | xargs grep -on Project.lib | grep -v ':0' and I like to add to this one liner the possibility to replace the string " Project.lib" that found ( more then once in file ) with "Example.lib" how can I do... (0 Replies)
Discussion started by: umen
0 Replies

3. Shell Programming and Scripting

Counting string of a variable

Hi, There is a variable f_name, it store some file names. Value of f_name=a.sql b.sql c.sql....... like this. want to count how many file name the var f_name stores. Without using loop is there any command to count that. (5 Replies)
Discussion started by: Dip
5 Replies

4. Shell Programming and Scripting

Replacing string in all instances (both filenames and file contents) in a directory

Hi, I have a set of files stored in a single directory that I use to set parameters for a physics code, and I would like to streamline the process of updating them all when I change a parameter. For instance, if the files are called A2000p300ini, A2000p300sub, A2000p300run, and the text in each... (3 Replies)
Discussion started by: BlueChris
3 Replies

5. Shell Programming and Scripting

How to select only the most frequent instances of a variable string in a file?

I've got a web access file that I want to grep (or awk or perl or whatever will work!) out the most frequent instances of unique IP entries. Meaning the file looks something like this: I'd like to run a sort or grep (or whatever) that will only select out the lines from IP's that had the... (7 Replies)
Discussion started by: kevinmccallum
7 Replies

6. UNIX for Dummies Questions & Answers

Help with counting string elements

Hi All, I hv several files which have hundreds of lines each for example>XYZ.abc01 NNNTCGGTNNNNNCCACACACMYACACACCCACACCCACSCARCAC I'd like to exculde the first line beginning with ">" and then for the rest of the lines get a count for each string element. So for the above example I would like... (8 Replies)
Discussion started by: pawannoel
8 Replies

7. Shell Programming and Scripting

count and number instances of a character in sed or awk

I currently use LaTeX together with a sed script to set cloze test papers for my students. I currently pepend and equals sign to the front of the words I want to leave out in the finished test, =perpendicular, for example. I am able to number the blanks using a variable in LaTeX. I would like to... (8 Replies)
Discussion started by: maouinin
8 Replies

8. Shell Programming and Scripting

Script counting instances of software running on a machine

Hello to all @here, as Iīm new to this forum, I will try to start in a easy way for my first post. Iīm not beginner in scripting, but also not a proffessional. So please keep easy, if I donīt understand your explanation at once ;) I donīt mean it in a bad way! Here is the Problem: There were... (2 Replies)
Discussion started by: muogli
2 Replies

9. Shell Programming and Scripting

count the number of instances in 2 columns using awk

Input A.1 Q.1 A.1 Q.2 A.1 Q.3 A.2 Q.4 Explanation: Final Output A.1 Q.1 s1 t1 A.1 Q.2 s1 t2 A.1 Q.3 s1 t3 A.2 Q.4 s5 t5 ---------- Post updated 09-28-12 at 03:38 AM ---------- Previous update was 09-27-12 at 09:10 AM ---------- Hi Guys, I was able to do until... (11 Replies)
Discussion started by: quincyjones
11 Replies

10. Shell Programming and Scripting

Counting a string between 2 strings...

I have been working on this for a little while and have been unable to come to a solution. Any help would be appreciated. I am working on a UNIX workstation and have a 30-40 meg text file that I am working with. In my real file there is hundreds of Jobs. Example of input file; misc logging data... (1 Reply)
Discussion started by: ny_evan
1 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy