Sponsored Content
Top Forums Shell Programming and Scripting How to find a count of a word within a file Post 302191439 by bd_joy on Friday 2nd of May 2008 02:51:53 PM
Old 05-02-2008
How to find a count of a word within a file

Hello,
I'm looking for a wait to count the number of occurrences of a certain string of characters within a file. The file that I trying to parce has segments within the file that have a header and footer to each segment and I'm trying to do a count of the header string and compare it to a count of the footer string to verify the integrity of the file.

Example file:
HEADER misc text and numeric values FOOTER HEADER more misc info FOOTER HEADER etc etc FOOTER

There are no carriage returns within the file, and it's about 50 to 60MB text file so the process needs to be somewhat efficient as a short processing timeframe is required.


I've done several searches and tried using wc, tr, and sort is a variety of different ways but I'm no closer to finding a solution. I'm a novice to the use of utilities like sed or awk, but ideas using them are welcome.

Other general info: I use ksh on AIX 5.3. Thanks for any help! Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count the number of occurence of perticular word from file

I want to count the number of occurence of perticular word from one text file. Please tell me "less" command is work in ksh or not. If it is not working then instead of that which command will work. :confused: (40 Replies)
Discussion started by: rinku
40 Replies

2. Shell Programming and Scripting

find a word in a file, and change a word beneath it ??

Hi all, I have a file with lines written somewhat like this. aaaa ccc aa linux browse = no xssxw cdcedc dcsdcd csdw police dwed dwd browse = no cdecec (2 Replies)
Discussion started by: vikas027
2 Replies

3. Shell Programming and Scripting

grep all records in a file and get a word count -perl

Hi, I have a file .. file.txt .. i need to get a total record count in the files into a $variable.. im using perl script thanks (4 Replies)
Discussion started by: meghana
4 Replies

4. Shell Programming and Scripting

how to count a word in a file

dear all, i have a requirement to count the errors and display from a file. eg. file1.txt sjdgfjdgfgd ora-0001 sdjgfydh sdukgh7 23 sjdgfjdgfgd ora-0002 sdjgfydhsf34 ew 34v sjdgfjdgfgd ora-0008 sdjgfydh asdf asdfas sjdgfjdgfgd ora-0001 sdjgfydhjkbs ui873 sjdgfjdgfgd ora-0004 sdjgfydh... (9 Replies)
Discussion started by: unx100
9 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 characters in a csv file and add an word.

Hello, I want to add a sentence to "post column" those who are only less than 30 characters.Thank you very much for your help. "category","title","post" "Z","Zoo","test 54325 test 45363mc." "Z","Zen","rs2w3rsj 2d342dg 2d3s4f23 d23423s23h 2s34s2423g ds232d34 2342." "Z","Zet","test4444... (3 Replies)
Discussion started by: hoo
3 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Taking word count from file and printing in file

hi, i am having a file which contains the below content, i need to take the word count of if and print the file name also inputfile.txt file_name1.txt,type_name1.txt file_name2.txt,type_name2.txt i would need the word count of the files like this if file_name*.txt then wc -l... (10 Replies)
Discussion started by: rohit_shinez
10 Replies

9. Shell Programming and Scripting

How to append word count at end of file?

Hi guys, I have to append the word count of a file at the end of the file name like this - > "filename_2345" where 2345 is the word count of "filename". How do i achieve this using one command ? I am not allowed to store the word count in a variable and then concatenate. Request your... (1 Reply)
Discussion started by: peter2312
1 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to check word count of each word in file

I am trying to figure out to find word count of each word from my file sample file hi how are you hi are you ok sample out put hi 1 how 1 are 1 you 1 hi 1 are 1 you 1 ok 1 wc -l filename is not helping , i think we will have to split the lines and count and then print and also... (4 Replies)
Discussion started by: mirwasim
4 Replies
SVNNOTIFY(1p)						User Contributed Perl Documentation					     SVNNOTIFY(1p)

Name
       svnnotify - Subversion activity notification

Usage
	 svnnotify --repos-path "$1" --revision "$2" [options]

Options
	 -p --repos-path PATH	      Path to the Subversion repository. Required.
	 -r --revision REVISION       Commit revision number. Required.
	 -t --to ADDRESS	      The notification destination email address.
				      Required unless --to-regex-map.
	 -x --to-regex-map TO=REGEX   A mapping between a destination email address
				      and a regular expression to match against the
				      directories affected by the commit. Required
				      unless --to or --to-email-map.
	    --to-email-map REGEX=TO   The inverse of --to-regex-map: Map a regular
				      expresion to an email address. Required unless
				      --to or --to-regex-map.
	 -f --from ADDRESS	      Email address to use in the From header.
	 -D --user-domain DOMAIN      Domain name to append to the username to
				      complete the email address in the From header.
	 -l --svnlook SVNLOOK	      Location of the svnlook executable.
	 -s --sendmail SENDMAIL       Location of the sendmail executable.
	 -E --set-sender	      Set the envelope sender to the from address.
	    --smtp ADDRESS	      Address for an SMTP server.
	    --smtp-user USERNAME      Username for authenticating to a SMTP server.
	    --smtp-pass PASSWORD      Password for authenticating to a SMTP server.
	    --smtp-authtype AUTHTYPE  Type of SMTP authentication.
	 -c --encoding ENCODING       The character encoding for reading and writing
				      data.
	    --svn-encoding ENCODING   The character encoding of the log message and
				      the repository files.
	    --diff-encoding ENCODING  The character encoding of the repository files.
	 -g --language LANGUAGE       Value for the Content-Language header and $LANG
				      environment variable.
	 -d --with-diff 	      Include the diff in the message.
	 -a --attach-diff	      Attach the diff to the message.
	 -w --diff-switches SWITCHES  Switches to pass to C<svnlook diff>.
	 -R --reply-to ADDRESS	      Address for use in the Reply-To header.
	    --add-header NAME=VALUE   Add an extra header to the email.
	 -P --subject-prefix PREFIX   String to prepend to the subject.
	 -C --subject-cx	      Include the context of the commit in the
				      subject.
	 -X --strip-cx-regex	      Regex to remove part of the CX file name from
				      the subject.
	 -O --no-first-line	      Do not include the first line of the log
				      message in the subject.
	 -i --max-sub-length LENGTH   Maximum size of the subject line.
	 -e --max-diff-length LENGTH  Maximum size of the diff output.
	 -H --handler HANDLER	      The notification handler, such as "HTML".
	 -F --filter FILTER	      An output filter, such as "Markdown".
	 -A --author-url URL	      Include link to specified author URL.
	 -U --revision-url URL	      Include links to specified Revision URL.
	 -T --rt-url URL	      Include links to specified Request Tracker URL.
	 -B --bugzilla-url URL	      Include links to specified Bugzilla URL.
	 -J --jira-url URL	      Include links to specified JIRA URL.
	 -G --gnats-url URL	      Include links to specified Gnats URL.
	    --ticket-map REGEX=URL    Regex and URL for custom ticket identifiers.
	    --header HEADER	      Text header to display before body.
	    --footer FOOTER	      Text footer to display at end of body.
	 -V --verbose		      Incremental verbose mode.
	 -h --help		      Print this usage statement and exit.
	 -m --man		      Print the complete documentation and exit.
	 -v --version		      Print the version number and exit.

       More options may be supported by the subclass of SVN::Notify specified by the "--handler" option or by filters specified by the "--filter"
       option. Consult the documentation of the relevant modules for details.

See Also
       See SVN::Notify for the complete documentation. If you're having issues with character encodings, see especially the Character Encoding
       Support section.

Author
       David E. Wheeler <david@kineticode.com>

Copyright and License
       Copyright (c) 2004-2009 Kineticode, Inc. Some Rights Reserved.

       This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl v5.10.1							    2011-03-15							     SVNNOTIFY(1p)
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy