Sponsored Content
Top Forums Shell Programming and Scripting Need to find occurrences of email domains in all files in a directory Post 302362252 by varontron on Thursday 15th of October 2009 11:29:54 AM
Old 10-15-2009
file 'test':
Code:
@www.test.com
@www.test.org
@www.test.com
@www.test.org
@www.test.com
@www.test.com
@www.test.com
@www.test.com
@

command
Code:
 perl -we 'my $domains = {};open FH, "<$ARGV[0]"; while (<FH>) {if (/\@([\w\.]+)/){$domains->{$1}+=1;}}foreach my $domain (sort keys %$domains){print "$domain"."=";print $domains->{$domain}."\n";};close FH;'  test

more easily read:
Code:
my $domains = {};
open FH, "<$ARGV[0]"; 
while (<FH>) {
  if (/\@([\w\.]+)/) {
    $domains->{$1}+=1;
  }
}
foreach my $domain (sort keys %$domains) {
  print "$domain"."=";
  print $domains->{$domain}."\n";
};
close FH;

result
Code:
www.test.com=6
www.test.org=2

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find and remove rows from file where multi occurrences of character found

I have a '~' delimited file of 6 - 7 million rows. Each row should contain 13 columns delimited by 12 ~'s. Where there are 13 tildes, the row needs to be removed. Each row contains alphanumeric data and occasionally a ~ ends up in a descriptive field and therefore acts as a delimiter, resulting in... (1 Reply)
Discussion started by: kpd
1 Replies

2. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies

3. Shell Programming and Scripting

Script to find and email selected files

I am trying to come up with a script that will search for selected files and then email them to me. For example, say I have a directory that has the following files: AA_doug.txt AA_andy.txt BB_john.txt APPLE_mike.txt GLOBE_ed.txt GLOBE_tony.txt TOTAL_carl.txt what is the best way to... (2 Replies)
Discussion started by: coach5779
2 Replies

4. Homework & Coursework Questions

Du without directory and Grep for occurrences of a word

Assistance on work Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Files stored in ... (1 Reply)
Discussion started by: alindner
1 Replies

5. Shell Programming and Scripting

Regex find first 5-7 occurrences of a set of digits within a string

Using these strings as an example: <a onclick="doShowCHys=1;ShowWindowN(0,'/daman/man.php?asv4=145148&amp;playTogether=True',960,540,943437);return false;" title=""> <a onclick="doShowCHys=1;ShowWindowN(0,'/daman/man.php?asv4=1451486&amp;playTogether=True',960,540,94343);return false;" title=""> <a... (12 Replies)
Discussion started by: metallica1973
12 Replies

6. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

7. UNIX for Advanced & Expert Users

Find 2 occurrences of a word and print file names

I was thinking something like this but it always gets rid of the file location. grep -roh base. | wc -l find . -type f -exec grep -o base {} \; | wc -l Would this be a job for awk? Would I need to store the file locations in an array? (3 Replies)
Discussion started by: cokedude
3 Replies

8. Shell Programming and Scripting

Loop multiple directory, find a file and send email

Hello ALL, need a BASH script who find file and send email with attachment. I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as... (1 Reply)
Discussion started by: penchev
1 Replies

9. Shell Programming and Scripting

Check Directory for files & Email

I'm working on a bash script to move files from one location, to two. The first part of my challenge is intended to check a particular directory for contents (e.g. files or other items in it), if files exists, then send the list of names to a txt file and email me the text file. If files do not... (4 Replies)
Discussion started by: Nvizn
4 Replies
atsopt(1)						      General Commands Manual							 atsopt(1)

NAME
atsopt - ATS to C compiler SYNOPSIS
atsopt <command>... DESCRIPTION
atsopt is the compiler from ATS to C. It is most commonly invoked by atscc which is the preferred frontend for compiling ATS code. COMMANDS
atsopt takes a number of commands with parameters to determine its behavior: -d, --dynamic <filenames> Dynamically load the filenames. --debug=1 Enable generation of debugging information. -dep, --depgen Generate dependency lists. -h, --help Print the usage information. -o, --output <filename> Specify the output filename. --posmark_html Generate an HTML file with colored concrete syntax. --posmark_xref Generate an HTML file with syntactic cross-references. -s, --static <filenames> Statically load the filenames. -tc, --typecheck Typecheck the given ATS source files, but go no further. -v, --version Show ATS/Anairiats version and gcc version. EXAMPLES
atsopt -o test.c -d test.dats Compile test.dats to a C file. atsopt -tc -d test.dats Typecheck test.dats only. atsopt -o test.html -d test.dats --posmark_html Write a syntax colored version of test.dats. SEE ALSO
atscc(1), atslex(1). These programs are documented fully by The ATS/Anairiats user's manual available via the web at http://www.ats-lang.org/ AUTHOR
atsopt was written by Hongwei Xi. This manual page was written by Matthew Danish <mrd@debian.org>, for the Debian project (and may be used by others). February 22, 2010 atsopt(1)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy