Sponsored Content
Top Forums Shell Programming and Scripting awk script to count characters in file 1 in file 2 Post 302795067 by Jotne on Wednesday 17th of April 2013 07:26:35 AM
Old 04-17-2013
Take some care when using match ($0, i)
Not sure what the intention of this counting is, but if the code have a line like abb it would be counted both as a and as b
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to count characters by line of file ?

Hello, Member or professional need help how to count characters by line of file Example of the file is here cdr20080817164322811681txt cdr20080817164322811txt cdr20080817164322811683txt cdr20080817164322811684txt I want to count the characters by line of file . The output that I... (4 Replies)
Discussion started by: ooilinlove
4 Replies

2. Shell Programming and Scripting

awk script to count percentage from log file

Hi, I have a log like this : actually i want to get the log like this : where % can get from : 100 * pmTotNoRrcConnectReqSucc / pmTotNoRrcConnectReq Thanks in advance.. :) (8 Replies)
Discussion started by: justbow
8 Replies

3. Shell Programming and Scripting

Include special system characters in file count

Hi, I have a script that checks the length of each record/line in file - This seems to be working when there are no special systems character that are invisible or hidden. awk -v file=$file '{ if (filename==file) { k+=$5 if (length() <= 10 ){print size length(), "bytes " k} }... (2 Replies)
Discussion started by: asemota
2 Replies

4. Shell Programming and Scripting

Unix Script file to Append Characters before rows in file.

Hi Experts, I am working on HP-UX. I am new to shell scripting. I would like to have a shell script which will prefix: 1. "H|" before first row of my file and, 2. "T" for all other rows of the file. For Example - File before running the script 20100430|4123451810|218.50|TC 20100430 ... (4 Replies)
Discussion started by: phani333
4 Replies

5. Shell Programming and Scripting

script to tail file; problem with awk and special characters

Trying to use code that I found to send only new lines out of a log file by doing: while :; do temp=$(tail -1 logfile.out) awk "/$last/{p=1}p" logfile.out #pipe this to log analyzer program last="$temp" sleep 10 done Script works fine when logfile is basic text, but when it contains... (2 Replies)
Discussion started by: moo72moo
2 Replies

6. Shell Programming and Scripting

Checking a pattern in file and the count of characters

I am having a zipped file which has the following URL contents - 98.70.217.222 - - "GET /liveupdate-aka.symantec.com/1340071490jtun_nav2k8enn09m25.m25?h=abcdefgh HTTP/1.1" 200 159229484 "-" "hBU1OhDsPXknMepDBJNScBj4BQcmUz5TwAAAAA" "-" In this line here is we only need to consider the... (4 Replies)
Discussion started by: Naks_Sh10
4 Replies

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

8. Shell Programming and Scripting

Speed : awk command to count the occurrences of fields from one file present in the other file

Hi, file1.txt AAA BBB CCC DDD file2.txt abc|AAA|AAAabcbcs|fnwufnq bca|nwruqf|AAA|fwfwwefwef fmimwe|BBB|fnqwufw|wufbqw wcdbi|CCC|wefnwin|wfwwf DDD|wabvfav|wqef|fwbwqfwfe i need the count of rows of file1.txt present in the file2.txt required output: AAA 2 (10 Replies)
Discussion started by: mdkm
10 Replies

9. Shell Programming and Scripting

Help with listing file name containing particular text and count of lines with 10 characters.

Hi, I've 2 queries. I need to list files which doesn't contain a particular text in the content. For example say, I need to list files which doesn't contain string "abc" from all files ending with *.bad. How can I do that? Also, I want to display number of lines in a file which has atleast... (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

10. Shell Programming and Scripting

awk script to detect specific string in a log file and count it

Hello, can someone guide me on this? I don't know what is the best approach, (awk script, shell script) I am using RedHat Linux version 6.5. There is a third party application deployed on that server. This app by default generates 5 log files and each file is 20MB. These log rollover... (5 Replies)
Discussion started by: ktisbest
5 Replies
cpc_count_usr_events(3CPC)												cpc_count_usr_events(3CPC)

NAME
cpc_count_usr_events, cpc_count_sys_events - enable and disable performance counters SYNOPSIS
cc [ flag... ] file... -lcpc [ library... ] #include <libcpc.h> int cpc_count_usr_events(int enable); int cpc_count_sys_events(int enable); In certain applications, it can be useful to explicitly enable and disable performance counters at different times so that the performance of a critical algorithm can be examined. The cpc_count_usr_events() function can be used to control whether events are counted on behalf of the application running in user mode, while cpc_count_sys_events() can be used to control whether events are counted on behalf of the application while it is running in the kernel, without otherwise disturbing the binding of events to the invoking LWP. If the enable argu- ment is non-zero, counting of events is enabled, otherwise they are disabled. Upon successful completion, cpc_count_usr_events() and cpc_count_sys_events() return 0. Otherwise, the functions return -1 and set errno to indicate the error. The cpc_count_usr_events() and cpc_count_sys_events() functions will fail if: EAGAIN The associated performance counter context has been invalidated by another process. EINVAL No performance counter context has been created, or an attempt was made to enable system events while delivering counter overflow signals. Example 1: Use cpc_count_usr_events() to minimize code needed by application. In this example, the routine cpc_count_usr_events() is used to minimize the amount of code that needs to be added to the application. The cputrack(1) command can be used in conjunction with these interfaces to provide event programming, sampling, and reporting facilities. If the application is instrumented in this way and then started by cputrack with the nouser flag set in the event specification, counting of user events will only be enabled around the critical code section of interest. If the program is run normally, no harm will ensue. int have_counters = 0; int main(int argc, char *argv[]) { if (cpc_version(CPC_VER_CURRENT) == CPC_VER_CURRENT && cpc_getcpuver() != -1 && cpc_access() == 0) have_counters = 1; /* ... other application code */ if (have_counters) (void) cpc_count_usr_events(1); /* ==> Code to be measured goes here <== */ if (have_counters) (void) cpc_count_usr_events(0); /* ... other application code */ } See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Interface Stability |Obsolete | +-----------------------------+-----------------------------+ cputrack(1), cpc(3CPC), cpc_access(3CPC), cpc_bind_event(3CPC), cpc_enable(3CPC), cpc_getcpuver(3CPC), cpc_pctx_bind_event(3CPC), cpc_ver- sion(3CPC), libcpc(3LIB), attributes(5) The cpc_count_usr_events() and cpc_count_sys_events() functions exist for binary compatibility only. Source containing these functions will not compile. These functions are obsolete and might be removed in a future release. Applications should use cpc_enable(3CPC) instead. 28 Mar 2005 cpc_count_usr_events(3CPC)
All times are GMT -4. The time now is 03:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy