Sponsored Content
Top Forums Shell Programming and Scripting Count number of occurrence of a string in file Post 302758625 by clx on Sunday 20th of January 2013 09:22:38 AM
Old 01-20-2013
Or ,

Code:
awk '{s+=gsub(/money king/,"money king") END {print s}}' file

with GNU grep

Code:
grep -o "money king" file | wc -l


Last edited by clx; 01-20-2013 at 10:27 AM.. Reason: fixed awk END part, thanks to vgersh99
This User Gave Thanks to clx For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

count the number of files which have a search string, but counting the file only once

I need to count the number of files which have a search string, but counting the file only once if search string is found. eg: File1: Please note that there are 2 occurances of "aaa" aaa bbb ccc aaa File2: Please note that there are 3 occurances of "aaa" aaa bbb ccc... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies

2. Shell Programming and Scripting

How to count number of occurances of string in a file?

Gurus, Need little guidance. I have A.txt and B.txt file. B.txt file contains Unique strings. Sample content of B.txt file for which i cut the fourth column uniquely and output directed to B.txt file And A.txt file contains the above string as a fourth column which is last column. So A.txt... (7 Replies)
Discussion started by: Shirisha
7 Replies

3. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

4. Shell Programming and Scripting

Replace x Number of String Occurrence with Sed

Ok, So I have a huge file that has over 12000 lines in it. in this file, there are 589 occurrences of the string "use five-minute-interval" spread in various areas in the file. How can i replace the the last 250 of the occurrences of "use five-minute-interval" with "use... (10 Replies)
Discussion started by: SkySmart
10 Replies

5. Shell Programming and Scripting

find string nth occurrence in file and print line number

Hi I have requirement to find nth occurrence in a file and capture data from with in lines (between lines) Data in File. <QUOTE> <SESSION> <ATTRIBUTE NAME='Parameter Filename' VALUE='file1.parm'/> <ATTRIBUTE NAME='Service Name' VALUE='None'/> </SESSION> <SESSION> <ATTRIBUTE... (6 Replies)
Discussion started by: tmalik79
6 Replies

6. Shell Programming and Scripting

Count number of occurrence at each line

Hi I have the following file ENST001 ENST002 4 4 4 88 9 9 ENST004 3 3 3 99 8 8 ENST009 ENST010 ENST006 8 8 8 77 8 8 Basically I want to count how many times ENST* is repeated in each line so the expected results is 2 1 3 Any suggestion please ? (4 Replies)
Discussion started by: fuad_
4 Replies

7. Shell Programming and Scripting

How to count the number of occurrence of words from multiple files?

File 1 aaa bbb ccc File 2 aaa xxx zzz bbb File 3 aaa bbb xxx Output: (4 Replies)
Discussion started by: Misa-Misa
4 Replies

8. Shell Programming and Scripting

How to count the occurrence of a number?

Hi, I have a file which contained a set of numbers like Col1 col2 col3 col4 1 sa 13 0 2 sb 14 0 3 sc 15 9 4 sd 16 -9 5 sd 20 -2 6 sd 20 4 Here in last column I need to count the zeros, positive values and negative values, please help me to do that. (2 Replies)
Discussion started by: Shenbaga.d
2 Replies

9. Shell Programming and Scripting

Count occurrence of string in a column using awk

Hi, I want to count the occurrences of strings in a column and display as in example below: Input: get1 345 789 098 get2 567 982 090 fet4 777 610 632 get1 800 544 230 get1 600 788 451 get2 892 321 243 get1 673 111 235 fet3 789 220 278 fet4 768 222 341 output: 4 get1 345 789... (7 Replies)
Discussion started by: aydj
7 Replies

10. UNIX for Dummies Questions & Answers

Count occurrence of string (based on type) in a column using awk

Hello, I have a table that looks like what is shown below: AA BB CC XY PQ RS AA BB CC XY RS I would like the total counts depending on the set they belong to: if search pattern is in {AA, BB, CC} --> count them as Type1 | wc -l (3 Replies)
Discussion started by: Gussifinknottle
3 Replies
std::moneypunct< _CharT, _Intl >(3cxx)									    std::moneypunct< _CharT, _Intl >(3cxx)

NAME
std::moneypunct< _CharT, _Intl > - SYNOPSIS
Inherits std::locale::facet, and std::money_base. Inherited by std::moneypunct_byname< _CharT, _Intl >. Public Types enum { _S_minus, _S_zero, _S_end } typedef __moneypunct_cache < _CharT, _Intl > __cache_type" enum part { none, space, symbol, sign, value } typedef _CharT char_type typedef basic_string< _CharT > string_type Public Member Functions moneypunct (size_t __refs=0) moneypunct (__cache_type *__cache, size_t __refs=0) moneypunct (__c_locale __cloc, const char *__s, size_t __refs=0) string_type curr_symbol () const char_type decimal_point () const int frac_digits () const string grouping () const string_type negative_sign () const string_type positive_sign () const char_type thousands_sep () const pattern pos_format () const pattern neg_format () const Static Public Member Functions static pattern _S_construct_pattern (char __precedes, char __space, char __posn) throw () Static Public Attributes static const char * _S_atoms static const pattern _S_default_pattern static locale::id id static const bool intl Protected Member Functions virtual ~moneypunct () void _M_initialize_moneypunct (__c_locale __cloc=0, const char *__name=0) template<> void _M_initialize_moneypunct (__c_locale, const char *) template<> void _M_initialize_moneypunct (__c_locale, const char *) template<> void _M_initialize_moneypunct (__c_locale, const char *) template<> void _M_initialize_moneypunct (__c_locale, const char *) virtual string_type do_curr_symbol () const virtual char_type do_decimal_point () const virtual int do_frac_digits () const virtual string do_grouping () const virtual pattern do_neg_format () const virtual string_type do_negative_sign () const virtual pattern do_pos_format () const virtual string_type do_positive_sign () const virtual char_type do_thousands_sep () const Static Protected Member Functions static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw () static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0) static void _S_destroy_c_locale (__c_locale &__cloc) static __c_locale _S_get_c_locale () static const char * _S_get_c_name () throw () static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s) Detailed Description template<typename _CharT, bool _Intl>class std::moneypunct< _CharT, _Intl > Primary class template moneypunct. This facet encapsulates the punctuation, grouping and other formatting features of money amount string representations. Definition at line 934 of file locale_facets_nonio.h. Member Typedef Documentation template<typename _CharT , bool _Intl> typedef _CharT std::moneypunct< _CharT, _Intl >::char_type Public typedefs. Definition at line 940 of file locale_facets_nonio.h. template<typename _CharT , bool _Intl> typedef basic_string<_CharT> std::moneypunct< _CharT, _Intl >::string_type Public typedefs. Definition at line 941 of file locale_facets_nonio.h. Constructor &; Destructor Documentation template<typename _CharT , bool _Intl> std::moneypunct< _CharT, _Intl >::moneypunct (size_t__refs = 0) [inline], [explicit] Constructor performs initialization. This is the constructor provided by the standard. Parameters: refs Passed to the base facet class. Definition at line 963 of file locale_facets_nonio.h. template<typename _CharT , bool _Intl> std::moneypunct< _CharT, _Intl >::moneypunct (__cache_type *__cache, size_t__refs = 0) [inline], [explicit] Constructor performs initialization. This is an internal constructor. Parameters: cache Cache for optimization. refs Passed to the base facet class. Definition at line 976 of file locale_facets_nonio.h. template<typename _CharT , bool _Intl> std::moneypunct< _CharT, _Intl >::moneypunct (__c_locale__cloc, const char *__s, size_t__refs = 0) [inline], [explicit] Internal constructor. Not for general use. This is a constructor for use by the library itself to set up new locales. Parameters: cloc The C locale. s The name of a locale. refs Passed to the base facet class. Definition at line 991 of file locale_facets_nonio.h. template<typename _CharT , bool _Intl> virtual std::moneypunct< _CharT, _Intl >::~moneypunct () [protected], [virtual] Destructor. Member Function Documentation template<typename _CharT , bool _Intl> string_type std::moneypunct< _CharT, _Intl >::curr_symbol () const [inline] Return currency symbol string. This function returns a string_type to use as a currency symbol. It does so by returning returning moneypunct<char_type>::do_curr_symbol(). Returns: string_type representing a currency symbol. Definition at line 1061 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_curr_symbol(). template<typename _CharT , bool _Intl> char_type std::moneypunct< _CharT, _Intl >::decimal_point () const [inline] Return decimal point character. This function returns a char_type to use as a decimal point. It does so by returning returning moneypunct<char_type>::do_decimal_point(). Returns: char_type representing a decimal point. Definition at line 1005 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_decimal_point(). template<typename _CharT , bool _Intl> virtual string_type std::moneypunct< _CharT, _Intl >::do_curr_symbol () const [inline], [protected], [virtual] Return currency symbol string. This function returns a string_type to use as a currency symbol. This function is a hook for derived classes to change the value returned. See Also: curr_symbol() for details. Returns: string_type representing a currency symbol. Definition at line 1207 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::curr_symbol(). template<typename _CharT , bool _Intl> virtual char_type std::moneypunct< _CharT, _Intl >::do_decimal_point () const [inline], [protected], [virtual] Return decimal point character. Returns a char_type to use as a decimal point. This function is a hook for derived classes to change the value returned. Returns: char_type representing a decimal point. Definition at line 1169 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::decimal_point(). template<typename _CharT , bool _Intl> virtual int std::moneypunct< _CharT, _Intl >::do_frac_digits () const [inline], [protected], [virtual] Return number of digits in fraction. This function returns the exact number of digits that make up the fractional part of a money amount. This function is a hook for derived classes to change the value returned. See Also: frac_digits() for details. Returns: Number of digits in amount fraction. Definition at line 1247 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::frac_digits(). template<typename _CharT , bool _Intl> virtual string std::moneypunct< _CharT, _Intl >::do_grouping () const [inline], [protected], [virtual] Return grouping specification. Returns a string representing groupings for the integer part of a number. This function is a hook for derived classes to change the value returned. See Also: grouping() for details. Returns: String representing grouping specification. Definition at line 1194 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::grouping(). template<typename _CharT , bool _Intl> virtual pattern std::moneypunct< _CharT, _Intl >::do_neg_format () const [inline], [protected], [virtual] Return pattern for money values. This function returns a pattern describing the formatting of a negative valued money amount. This function is a hook for derived classes to change the value returned. See Also: neg_format() for details. Returns: Pattern for money values. Definition at line 1275 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::neg_format(). template<typename _CharT , bool _Intl> virtual string_type std::moneypunct< _CharT, _Intl >::do_negative_sign () const [inline], [protected], [virtual] Return negative sign string. This function returns a string_type to use as a sign for negative amounts. This function is a hook for derived classes to change the value returned. See Also: negative_sign() for details. Returns: string_type representing a negative sign. Definition at line 1233 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::negative_sign(). template<typename _CharT , bool _Intl> virtual pattern std::moneypunct< _CharT, _Intl >::do_pos_format () const [inline], [protected], [virtual] Return pattern for money values. This function returns a pattern describing the formatting of a positive valued money amount. This function is a hook for derived classes to change the value returned. See Also: pos_format() for details. Returns: Pattern for money values. Definition at line 1261 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::pos_format(). template<typename _CharT , bool _Intl> virtual string_type std::moneypunct< _CharT, _Intl >::do_positive_sign () const [inline], [protected], [virtual] Return positive sign string. This function returns a string_type to use as a sign for positive amounts. This function is a hook for derived classes to change the value returned. See Also: positive_sign() for details. Returns: string_type representing a positive sign. Definition at line 1220 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::positive_sign(). template<typename _CharT , bool _Intl> virtual char_type std::moneypunct< _CharT, _Intl >::do_thousands_sep () const [inline], [protected], [virtual] Return thousands separator character. Returns a char_type to use as a thousands separator. This function is a hook for derived classes to change the value returned. Returns: char_type representing a thousands separator. Definition at line 1181 of file locale_facets_nonio.h. Referenced by std::moneypunct< _CharT, _Intl >::thousands_sep(). template<typename _CharT , bool _Intl> int std::moneypunct< _CharT, _Intl >::frac_digits () const [inline] Return number of digits in fraction. This function returns the exact number of digits that make up the fractional part of a money amount. It does so by returning returning moneypunct<char_type>::do_frac_digits(). The fractional part of a money amount is optional. But if it is present, there must be frac_digits() digits. Returns: Number of digits in amount fraction. Definition at line 1111 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_frac_digits(). template<typename _CharT , bool _Intl> string std::moneypunct< _CharT, _Intl >::grouping () const [inline] Return grouping specification. This function returns a string representing groupings for the integer part of an amount. Groupings indicate where thousands separators should be inserted. Each char in the return string is interpret as an integer rather than a character. These numbers represent the number of digits in a group. The first char in the string represents the number of digits in the least significant group. If a char is negative, it indicates an unlimited number of digits for the group. If more chars from the string are required to group a number, the last char is used repeatedly. For example, if the grouping() returns 0302 and is applied to the number 123456789, this corresponds to 12,34,56,789. Note that if the string was 32, this would put more than 50 digits into the least significant group if the character set is ASCII. The string is returned by calling moneypunct<char_type>::do_grouping(). Returns: string representing grouping specification. Definition at line 1048 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_grouping(). template<typename _CharT , bool _Intl> pattern std::moneypunct< _CharT, _Intl >::neg_format () const [inline] Return pattern for money values. This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning returning moneypunct<char_type>::do_pos_format() or moneypunct<char_type>::do_neg_format(). The pattern has 4 fields describing the ordering of symbol, sign, value, and none or space. There must be one of each in the pattern. The none and space enums may not appear in the first field and space may not appear in the final field. The parts of a money string must appear in the order indicated by the fields of the pattern. The symbol field indicates that the value of curr_symbol() may be present. The sign field indicates that the value of positive_sign() or negative_sign() must be present. The value field indicates that the absolute value of the money amount is present. none indicates 0 or more whitespace characters, except at the end, where it permits no whitespace. space indicates that 1 or more whitespace characters must be present. For example, for the US locale and pos_format() pattern {symbol,sign,value,none}, curr_symbol() == '$' positive_sign() == '+', and value 10.01, and options set to force the symbol, the corresponding string is $+10.01. Returns: Pattern for money values. Definition at line 1151 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_neg_format(). template<typename _CharT , bool _Intl> string_type std::moneypunct< _CharT, _Intl >::negative_sign () const [inline] Return negative sign string. This function returns a string_type to use as a sign for negative amounts. It does so by returning returning moneypunct<char_type>::do_negative_sign(). If the return value contains more than one character, the first character appears in the position indicated by neg_format() and the remainder appear at the end of the formatted string. Returns: string_type representing a negative sign. Definition at line 1095 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_negative_sign(). template<typename _CharT , bool _Intl> pattern std::moneypunct< _CharT, _Intl >::pos_format () const [inline] Return pattern for money values. This function returns a pattern describing the formatting of a positive or negative valued money amount. It does so by returning returning moneypunct<char_type>::do_pos_format() or moneypunct<char_type>::do_neg_format(). The pattern has 4 fields describing the ordering of symbol, sign, value, and none or space. There must be one of each in the pattern. The none and space enums may not appear in the first field and space may not appear in the final field. The parts of a money string must appear in the order indicated by the fields of the pattern. The symbol field indicates that the value of curr_symbol() may be present. The sign field indicates that the value of positive_sign() or negative_sign() must be present. The value field indicates that the absolute value of the money amount is present. none indicates 0 or more whitespace characters, except at the end, where it permits no whitespace. space indicates that 1 or more whitespace characters must be present. For example, for the US locale and pos_format() pattern {symbol,sign,value,none}, curr_symbol() == '$' positive_sign() == '+', and value 10.01, and options set to force the symbol, the corresponding string is $+10.01. Returns: Pattern for money values. Definition at line 1147 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_pos_format(). template<typename _CharT , bool _Intl> string_type std::moneypunct< _CharT, _Intl >::positive_sign () const [inline] Return positive sign string. This function returns a string_type to use as a sign for positive amounts. It does so by returning returning moneypunct<char_type>::do_positive_sign(). If the return value contains more than one character, the first character appears in the position indicated by pos_format() and the remainder appear at the end of the formatted string. Returns: string_type representing a positive sign. Definition at line 1078 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_positive_sign(). template<typename _CharT , bool _Intl> char_type std::moneypunct< _CharT, _Intl >::thousands_sep () const [inline] Return thousands separator character. This function returns a char_type to use as a thousands separator. It does so by returning returning moneypunct<char_type>::do_thousands_sep(). Returns: char_type representing a thousands separator. Definition at line 1018 of file locale_facets_nonio.h. References std::moneypunct< _CharT, _Intl >::do_thousands_sep(). Member Data Documentation template<typename _CharT , bool _Intl> locale::id std::moneypunct< _CharT, _Intl >::id [static] Numpunct facet id. Definition at line 953 of file locale_facets_nonio.h. template<typename _CharT , bool _Intl> const bool std::moneypunct< _CharT, _Intl >::intl [static] This value is provided by the standard, but no reason for its existence. Definition at line 951 of file locale_facets_nonio.h. Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ Tue Nov 27 2012 std::moneypunct< _CharT, _Intl >(3cxx)
All times are GMT -4. The time now is 06:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy