Sponsored Content
Top Forums UNIX for Beginners Questions & Answers UNIX script to check word count of each word in file Post 302986006 by RavinderSingh13 on Friday 18th of November 2016 06:29:42 AM
Old 11-18-2016
Hello mirwasim,

Could you please try following and let me know if this helps you(If you are not worried about the sequence of your strings).
Code:
awk '{++A[$0]} END{for(i in A){print i, A[i]}}' RS='[ |\n]'   Input_file

Output will be as follows.
Code:
are 2
hi 2
how 1
ok 1
you 2

Thanks,
R. Singh
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies

2. UNIX for Dummies Questions & Answers

script to count a word in a flie

hi All, I have one question to have a answer with your help. i need to have a script for searching a file with .log extension form all directories. search for a word " Pass" in the files and to count the occurence of the word "Pass". i need all your help to solve the problem. Thanks,... (3 Replies)
Discussion started by: sipmohan
3 Replies

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

4. Shell Programming and Scripting

Word count of lines ending with certain word

Hi all, I am trying to write a command that can help me count the number of lines in the /etc/passwd file ending in bash. I have read through other threads but am yet to find one indicating how to locate a specifc word at the end of a line. I know i will need to use the wc command but when i... (8 Replies)
Discussion started by: warlock129
8 Replies

5. Shell Programming and Scripting

perl (word by word check if a hash key)

Hi, Now i work in a code that 1-get data stored in the database in the form of hash table with a key field which is the " Name" 2-in the same time i open a txt file and loop through it word by word 3- which i have a problem in is that : I need to loop word by word and check if it is a... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

6. Shell Programming and Scripting

~~Unix command to count a particular word in the whole directory .~~

Hi , i'm trying to count a particular word occurance in a whole directory..is this possible :wall: say for example there is a directory with 100 files which and all the file may have the word 'aaa' in it ...how would i count the number of 'aaa' in those whole 100 files in a directory ? ... (10 Replies)
Discussion started by: Rabbitsfoot
10 Replies

7. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

8. Shell Programming and Scripting

Word Count In A Script

I am in need of a basic format to 1. list all files in a directory 2. list the # of lines in each file 3. list the # of words in each file If someone could give me a basic format i would appreicate it ***ALSO i can not use the FIND command*** (4 Replies)
Discussion started by: domdom110
4 Replies

9. Shell Programming and Scripting

Word count files in UNIX

My files: file1 and file2 contain 157 words. Emptyfile1 contain 0 words. My script has to output how many files is filled with words and how many that are not. If there are files that have words in it. It has to output "file2 and file2 contains 157 words, 0 files are empty" If not every... (9 Replies)
Discussion started by: johnrichards
9 Replies
SQL::ReservedWords::MySQL(3pm)				User Contributed Perl Documentation			    SQL::ReservedWords::MySQL(3pm)

NAME
SQL::ReservedWords::MySQL - Reserved SQL words by MySQL SYNOPSIS
if ( SQL::ReservedWords::MySQL->is_reserved( $word ) ) { print "$word is a reserved MySQL word!"; } DESCRIPTION
Determine if words are reserved by MySQL. METHODS
is_reserved( $word ) Returns a boolean indicating if $word is reserved by either MySQL 3.2, 4.0, 4.1, 5.0 or 5.1. is_reserved_by_mysql3( $word ) Returns a boolean indicating if $word is reserved by MySQL 3.2. is_reserved_by_mysql4( $word ) Returns a boolean indicating if $word is reserved by either MySQL 4.0 or 4.1. is_reserved_by_mysql5( $word ) Returns a boolean indicating if $word is reserved by either MySQL 5.0 or 5.1. reserved_by( $word ) Returns a list with MySQL versions that reserves $word. words Returns a list with all reserved words. EXPORTS
Nothing by default. Following subroutines can be exported: is_reserved is_reserved_by_mysql3 is_reserved_by_mysql4 is_reserved_by_mysql5 reserved_by words SEE ALSO
SQL::ReservedWords <http://dev.mysql.com/doc/> AUTHOR
Christian Hansen "chansen@cpan.org" COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.8 2008-03-28 SQL::ReservedWords::MySQL(3pm)
All times are GMT -4. The time now is 05:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy