Sponsored Content
Top Forums UNIX for Dummies Questions & Answers count occurrences and substitute with counter Post 302168159 by ptob on Sunday 17th of February 2008 11:02:06 AM
Old 02-17-2008
...I guess the problem is that I'm not talking about the XXX being on a single line, but spread over the whole textfile!

Is this also possible with awk? Remember - I dunno the number of occurences of XXX in advance! Smilie
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search and Count Occurrences of Pattern in a File

I need to search and count the occurrences of a pattern in a file. The catch here is it's a pattern and not a word ( not necessarily delimited by spaces). For eg. if ABCD is the pattern I need to search and count, it can come in all flavors like (ABCD, ABCD), XYZ.ABCD=100, XYZ.ABCD>=500,... (6 Replies)
Discussion started by: tektips
6 Replies

2. Shell Programming and Scripting

Count the number of occurrences of the word

I am a newbie in UNIX shell script and seeking help on this UNIX function. Please give me a hand. Thanks. I have a large file. Named as 'MyFile'. It was tab-delmited. I am told to write a shell function that counts the number of occurrences of the ord “mysring” in the file 'MyFile'. (1 Reply)
Discussion started by: duke0001
1 Replies

3. Shell Programming and Scripting

Help with Unix and Awk to count number of occurrences

Hi, I have a file (movies.sh), this file contains list of movies such as I want to redirect the movies from movies.sh to file_to_process to allow me process the file with out losing anything. I have tried Movies.sh >> file_to_process But I want to add the row number to the data... (2 Replies)
Discussion started by: INHF
2 Replies

4. Shell Programming and Scripting

Count occurrences in awk

Hello, I have an output from GDB with many entries that looks like this 0x00007ffff7dece94 39 in dl-fini.c 0x00007ffff7dece97 39 in dl-fini.c 0x00007ffff7ab356c 50 in exit.c 0x00007ffff7aed9db in _IO_cleanup () at genops.c:1022 115 in dl-fini.c 0x00007ffff7decf7b in _dl_sort_fini (l=0x0,... (6 Replies)
Discussion started by: ikke008
6 Replies

5. Shell Programming and Scripting

Script to count word occurrences, but exclude some?

I am trying to count the occurrences of ALL words in a file. However, I want to exclude certain words: short words (i.e. <3 chars), and words contained in an blacklist file. There is also a desire to count words that are capitalized (e.g. proper names). I am not 100% sure where the line on... (5 Replies)
Discussion started by: Cronk
5 Replies

6. Shell Programming and Scripting

How to count occurrences in a specific column

Hi, I need help to count the number of occurrences in $3 of file1.txt. I only know how to count by checking one by one and the code is like this: awk '$3 ~ /aku hanya poyo/ {++c} END {print c}' FS="\t" file1.txt But this is not wise to do as i have hundreds of different occurrences in that... (10 Replies)
Discussion started by: redse171
10 Replies

7. Shell Programming and Scripting

awk Group By and count string occurrences

Hi Gurus, I'm scratching my head over and over and couldn't find the the right way to compose this AWK properly - PLEASE HELP :confused: Input: c,d,e,CLICK a,b,c,CLICK a,b,c,CONV c,d,e,CLICK a,b,c,CLICK a,b,c,CLICK a,b,c,CONV b,c,d,CLICK c,d,e,CLICK c,d,e,CLICK b,c,d,CONV... (6 Replies)
Discussion started by: Royi
6 Replies

8. Shell Programming and Scripting

Count occurrences in first column

input amex-11 10 abc amex-11 20 bcn amed-12 1 abc I tried something like this. awk '{h++}; END { for(k in h) print k, h }' rm1 output amex-11 1 10 abc amex-11 1 20 bcn amed-12 2 1 abc Note: The second column represents the occurrences. amex-11 is first one and amed-12 is the... (5 Replies)
Discussion started by: quincyjones
5 Replies

9. Shell Programming and Scripting

Count the number of string occurrences to display 0 entries in output

Hello Friends, Can somebody assist an issue I am having? I have a separate file with a list of account ids XXX200B02Y01 XXX200B03Y01 XXX200B05Y01 XXX200B07Y01 XXX200B08Y01 I call the file, and run an egrep against a directory and logfiles AccountID=$(cat... (2 Replies)
Discussion started by: liketheshell
2 Replies
PERLKO(1)						 Perl Programmers Reference Guide						 PERLKO(1)

X XXX perldocX XX XX XX XX XX XXXX X XXX XXX XXXX XX XX =head, =item, 'L' XX XXXXXX.  X XXX XX perldocX XX XX XXXX XXX X XXX XX POD XXXX XX XXXX.
X XXX XX perlpod XXXX XXXXXX.

NAME
perlko - PerlX XXX XXX DESCRIPTION
PerlX XXX XX XX XXXXX ! PerlX 5.8.0XXX XXXX/ISO 10646X XX XXXX XXX XXX. XXXX XXX XXXX XXXX XXX XX XXXX XXXX XXX XX XXX XXX XX XXX XX XXX XXXX XXXXX. XXXXX X XXXX XXX XX XXX XX XX XX - XXX XX XXX, XX XXX, XXX XXX, XXX XX XXXX XXX XX XXXX, XX XX, XXX XX, XXXX XX, XXXX XX, XXXX XX, XX XXXX XX XX X-X XXXX XX XXX XX XX XXX XXX XXX X XX X XX XXX XX XXX XXX XX XXX XXXX X X XX XX XXX XXXX XX XX XXXX XXXX XX XX XX XX XXX XXXX XXXX. PerlX XXXXX XXXXX XX XXX XX XXXXX. XX XXXXX XXX Perl XXXX XXX UTF-8 XXXX X X XX, XX XXX XXX(XX XX, XXX, index, substr)X XXX XX XX XXXX XX XXX XXXXX. (X XXX XX perlunicode XXXX XXXXXX.) XXXXX XX XXXX XX XX XXX XXX, XXX XX XXX XX XX/X XXX XXXXX XXXX XX XX XXXXX X XXXX XXX XXX XX XX XX 'Encode'X XXXXX. XXXX 'Encode'X XX XXX XXX XXX XXX XX X X XXXX. 'Encode'X XXX XX XXX XXXX XXXXX. o euc-kr US-ASCIIX KS X 1001X XX XX XXXXX XXX (XX XXXXXX XX.) KS X 2901X RFC 1557 XX. o cp949 MS-Windows 9x/MEXX XXX XX XXX. euc-krX 8,822XX XX XXX XX XX. aliasX uhc, windows-949, x-windows-949, ks_c_5601-1987. X XXX XXX XXXX XX XXXXX, Microsoft XXXX CP949X XXX XXX XX. o johab KS X 1001:1998 XX 3XX XXX XXX. XX XXXXX cp949X XXXXX US-ASCIIX KS X 1001X 8,822XX XX XXX XX XX. XXX XXX XX XX. o iso-2022-kr RFC 1557XX XXX XXX XXX XX XXX XXXXX US-ASCIIX KS X 1001X XXXXX XX XXX euc-krX XXX XXX XXX XX. 1997-8X XXX XXXX X XX XX XXX XXX XX. o ksc5601-raw KS X 1001(KS C 5601)X GL(X, MSBX 0XX X XX) X XXX XX XXX. US-ASCIIX XXXX XX XXXX XXX XX X11 XXX XX XXX (ksc5601.1987-0. '0'X GLX XXX.)XX XXX XX XXXXX XX XX. KS C 5601X 1997X KS X 1001X XXX XXXX. 1998XXX X XX (XXX XXX XX XX XX)X XXXX. X XX XX XXX XXX XXXX. XX XX, euc-kr XXXXX X XXX UTF-8X XXXXX XXX XX XX XXX. perl -Mencoding=euc-kr,STDOUT,utf8 -pe1 < file.euckr > file.utf8 XXXX XXX XX X X XXXX. perl -Mencoding=utf8,STDOUT,euc-kr -pe1 < file.utf8 > file.euckr XX XXX XX XXXX X X XXX Encode XXX XX XXXX PerlXX XX piconvX PerlX XX XXXX. X XXXX X X XXX piconvX UnixX XX iconvX XXX X XXXX. X XXXX XXX XXXX. piconv -f euc-kr -t utf8 < file.euckr > file.utf8 piconv -f utf8 -t euc-kr < file.utf8 > file.euckr X, 'PerlIO::encoding' XXX XX XXX XXXX XXX XX XX (XXX XXX XXX) XXX XX X X XXXX. #!/path/to/perl use encoding 'euc-kr', STDIN => 'euc-kr', STDOUT-> 'euc-kr', STDERR=>'euc-kr'; print length("XX"); # 2 (X XXXX XX XX XXX XX) print length('XX'); # 4 (XX XXXX XXX XX XXX XX) print index("XX, XXX", "X"); # -1 ('X'X XX) print index('XX, XXX', 'X'); # 7 (8XXX 9XX XXXX 'X'X XXXX XXX.) X XXX XX XXX... PerlX XXXX XXX XXX XXX XX XX XX, X XXX XX Perl XX X XXX XXXX XX, EncodeX XXX XX XX XX XX X XXXX. XX X XXX XX XX XXX XX XXXX. Perl XX XX XXX XXX XX XXX XXX XX XXX XXXX. X XXX XX XXX XX XXX XX XXXX XX XX XXXX. <http://www.perl.com/> O'ReillyX Perl X XXX <http://www.cpan.org/> Comprehensive Perl Archive Network <http://lists.perl.org/> Perl XXX XXX. XX XXX XXX perl-unicodeXX 'Encode'X XX XXX. PerlX X XX XXXXX XXX X X XX XXX XX XXX <http://www.perl.or.kr/> Perl XX XXX XX <news:han.comp.lang.perl/> XXX Perl XX XX <http://www.hanb.co.kr/search/searchResult.html?keyword=perl> O'ReillyXX XX XXX Perl XX XX <http://www.perlschool.net/> Perl XX XX X XX, XX XX, XX XX XXX XX <http://www.perl.co.kr> PerlX XXX CGI, DB, XX XX XX XX X XX XX XXXX X XXX XXX XX XX <http://www.unicode.org/> XXXX XXXX. <http://std.dkuug.dk/JTC1/SC2/WG2> XXXXX UnicodeX XX ISO XXX ISO/IEC 10646 UCS(Universal Character Set)X XXX ISO/IEC JTC1/SC2/WG2X X XXX. <http://www.cl.cam.ac.uk/~mgk25/unicode.html> XXX/XXXXX XXXXX UTF-8 XXX XX XXX(FAQ) <http://wiki.kldp.org/Translations/html/UTF8-Unicode-KLDP/UTF8-Unicode-KLDP.html> XXX/XXXXX XXXXX UTF-8 XXX XX XXX(FAQ)X XXX XX SEE ALSO
Encode, Encode::KR, encoding, perluniintro, perlunicode AUTHORS
Jarkko Hietaniemi <jhi@iki.fi> XXX <jshin@mailaps.org> perl v5.18.2 2014-01-06 PERLKO(1)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy