Sponsored Content
Top Forums Shell Programming and Scripting Count number of digits in a word Post 302273802 by cfajohnson on Tuesday 6th of January 2009 12:45:44 AM
Old 01-06-2009
Code:
$ WORD=abcd1234
$ count=${#WORD}
$ echo $count
8

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

word count showing wrong number of lines

Hi , I am using SUN OS Version 5.6. I have a file that contains records of length 270. when I do 'set nu' in vi editor, I get the count as 86. whereas when I do "wc -l" on the command prompt, it shows the count as only 85. this is very strange. why would the 'wc' show 1 record less. The job... (3 Replies)
Discussion started by: tselvanin
3 Replies

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

3. Shell Programming and Scripting

scripting - write a script that will count the number of times a particular word

hello everyone, I'm trying to learn some scripts but i cant get my head around two of them. 1. how can i write a script that will count the number of times a particular word is used in file? 2. how can i make a script that will take me to a web page from unix? if anyone could help it... (3 Replies)
Discussion started by: BigTool4u2
3 Replies

4. UNIX for Dummies Questions & Answers

Count number of occurences of a word

I want to count the number of occurences of say "200" in a file but that file also contains various stuff including dtaes like 2007 or smtg like 200.1 so count i am getting by doing grep -c "word" file is wrong Please help!!!!! (8 Replies)
Discussion started by: shikhakaul
8 Replies

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

6. Shell Programming and Scripting

Need script to count specific word and iterate over number of files.

Hi Experts, I want to know the count of specific word in a file. I have almost 600+ files. So I want to loop thru each file and get the count of the specific word. Please help me on achieving this... Many thanks (2 Replies)
Discussion started by: elamurugu
2 Replies

7. Shell Programming and Scripting

number of digits after decimal

Hi All, I have a file of decimal numbers, cat file1.txt 1.1382666907 1.2603107334 1.6118799297 24.4995857056 494.7632588468 560.7633734425 ..... I want to see the output as only 7 digits after decimal (5 Replies)
Discussion started by: senayasma
5 Replies

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

9. Shell Programming and Scripting

Find number of digits in a word

HI, Can you tell me how to find the number of digits in a word. $cat data.txt +123456ad 87645768 Output should be 6 8 (5 Replies)
Discussion started by: ashwin3086
5 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
monitor(3C)						   Standard C Library Functions 					       monitor(3C)

NAME
monitor - prepare process execution profile SYNOPSIS
#include <mon.h> void monitor(int (*lowpc(), int (*highpc)(), WORD *buffer, size_t bufsize, size_t nfunc); DESCRIPTION
The monitor() function is an interface to the profil(2) function and is called automatically with default parameters by any program created by the cc(1B) utility with the -p option specified. Except to establish further control over profiling activity, it is not necessary to explicitly call monitor(). When used, monitor() is called at least at the beginning and the end of a program. The first call to monitor() initiates the recording of two different kinds of execution-profile information: execution-time distribution and function call count. Execution-time distribution data is generated by profil() and the function call counts are generated by code supplied to the object file (or files) by cc(1B) -p. Both types of information are collected as a program executes. The last call to monitor() writes this collected data to the output file mon.out. The name of the file written by monitor() is controlled by the environment variable PROFDIR. If PROFDIR does not exist, the file mon.out is created in the current directory. If PROFDIR exists but has no value, monitor() does no profiling and creates no output file. If PROFDIR is dirname, and monitor() is called automatically by compilation with cc -p, the file created is dirname/pid.progname where progname is the name of the program. The lowpc and highpc arguments are the beginning and ending addresses of the region to be profiled. The buffer argument is the address of a user-supplied array of WORD (defined in the header <mon.h>). The buffer argument is used by moni- tor() to store the histogram generated by profil() and the call counts. The bufsize argument identifies the number of array elements in buffer. The nfunc argument is the number of call count cells that have been reserved in buffer. Additional call count cells will be allocated auto- matically as they are needed. The bufsize argument should be computed using the following formula: size_of_buffer = sizeof(struct hdr) + nfunc * sizeof(struct cnt) + ((highpc-lowpc)/BARSIZE) * sizeof(WORD) + sizeof(WORD) - 1 ; bufsize = (size_of_buffer / sizeof(WORD)); where: o lowpc, highpc, nfunc are the same as the arguments to monitor(); o BARSIZE is the number of program bytes that correspond to each histogram bar, or cell, of the profil() buffer; o the hdr and cnt structures and the type WORD are defined in the header <mon.h>. The default call to monitor() is as follows: monitor (&eprol, &etext, wbuf, wbufsz, 600); where: o eprol is the beginning of the user's program when linked with cc -p (see end(3C)); o etext is the end of the user's program (see end(3C)); o wbuf is an array of WORD with wbufsz elements; o wbufsz is computed using the bufsize formula shown above with BARSIZE of 8; o 600 is the number of call count cells that have been reserved in buffer. These parameter settings establish the computation of an execution-time distribution histogram that uses profil() for the entire program, initially reserves room for 600 call count cells in buffer, and provides for enough histogram cells to generate significant distribution- measurement results. For more information on the effects of bufsize on execution-distribution measurements, see profil(2). EXAMPLES
Example 1: Example to stop execution monitoring and write the results to a file. To stop execution monitoring and write the results to a file, use the following: monitor((int (*)())0, (int (*)())0, (WORD *)0, 0, 0); Use prof to examine the results. USAGE
Additional calls to monitor() after main() has been called and before exit() has been called will add to the function-call count capacity, but such calls will also replace and restart the profil() histogram computation. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
cc(1B), profil(2), end(3C), attributes(5), prof(5) SunOS 5.10 29 Dec 1996 monitor(3C)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy