Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to count the occurence of a character in a line Post 302262021 by sumit207 on Wednesday 26th of November 2008 07:36:33 AM
Old 11-26-2008
Bug How to count the occurence of a character in a line

Suppose i have data like :-

1,2,3,4,5
a,b,c
x,y,z,t


I want to count the occurence of , (comma) in every line.

Waiting for a solution.Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting occurence of a particular character on each line

Hi, I have the following data in a flat file: abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 I need to check the no. of occurence of "|" (pipe) on each line and the output should look like below:... (4 Replies)
Discussion started by: hey_mak
4 Replies

2. UNIX for Dummies Questions & Answers

How to count the occurence of a character in a line

Suppose i have data like :- 1,2,3,4,5 a,b,c x,y,z,t I want to count the occurence of , (comma) in every line. Waiting for a solution. (5 Replies)
Discussion started by: sumit207
5 Replies

3. UNIX for Advanced & Expert Users

Count specific word or character per line

Hi, I need help regarding counting specific word or character per line and validate it against a specific number i.e 10. And if number of character equals the specific number then that line will be part of the output. Specific number = 6 Specific word or char = || Sample data:... (1 Reply)
Discussion started by: janzper
1 Replies

4. Shell Programming and Scripting

Count character in one line

Please check the attachment for the example. Purpose: count how many "|" character in one line and also display the line number. expect result: Line 1 : there are 473 "|" characters Line 2 : there are 473 "|" characters I have tried to use awk to count it, it's ok when the statistic... (8 Replies)
Discussion started by: ambious
8 Replies

5. Shell Programming and Scripting

Count number of character occurence but not from quotation marks

I have the following string: 31-01-2012, 09:42:37;OK;94727132638;"Mozilla/5.0 (Linux; U; Android 2.2.1)";3G;WAP;I need a script which is counting the occurrence of semicolons ( ; ) but exclude the ones from the quotation marks. In the string given as example there are 8 semicolons but the script... (3 Replies)
Discussion started by: calinlicj
3 Replies

6. UNIX for Dummies Questions & Answers

Script to count character present in a line

Suppose i have multiple line like below in a file. ASDFAFAGAHAHAHA AGAHAHAJGAFAGAH AHAHAKAHAHAHAKA I need a bash script to count a character and also Also count the number of character present in each line . suppose for line 1: A=x, S=y, D=x and so on and total character=15. where x y and z is... (3 Replies)
Discussion started by: XXLMMN
3 Replies

7. Shell Programming and Scripting

Character count of each line

Hi, I have a file with more than 1000 lines. Most of the lines have 16 characters. I want to find out lines that have less than 14 characters (usually 12 or 13). wc -l gives me the line count and wc -c gives me the total characters in a file. I could not get the total characters for each line.... (1 Reply)
Discussion started by: bobbygsk
1 Replies

8. UNIX for Dummies Questions & Answers

Getting the character count of the last line

I need the character count of the last line of each file in a directory, and not the total. Now I have been doing this but unfortunately, -exec doesn't support pipes: find sent/ -type f -exec tail -1|wc -c {} \; If I try this: find sent/ -type f -exec tail -1 {} \; | wc -c It will give... (6 Replies)
Discussion started by: MIA651
6 Replies

9. Shell Programming and Scripting

sed - remove begin of line up to the third and including occurence of character

hello. How to remove all characters in a line from first character ( a $ ) until and including the third occurrence of that character ( $ ). Any help is welcome. (10 Replies)
Discussion started by: jcdole
10 Replies

10. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
dpa(1)							      General Commands Manual							    dpa(1)

NAME
dpa - DNS Packet Analyzer. Analyze DNS packets in ip trace files SYNOPSIS
dpa [ OPTION ] TRACEFILE DESCRIPTION
dpa is used to analyze dns packets in trace files. It has 3 main options: count, filter, and count uniques (i.e. count all different occurences). OPTIONS
-c expressionlist Count occurrences of matching expressions -f expression Filter: only process packets that match the expression -h Show usage -p Show the total number of correct DNS packets, and percentage of -u and -c values (of the total of matching on the -f filter. if no filter is given, percentages are on all correct dns packets) -of file Write all packets that match the -f flag to file, as pcap data. -ofh file Write all packets that match the -f flag to file, in hexadecimal format, readable by drill. -s Show possible match names -s matchname show possible match operators and values for name -sf Only evaluate packets (in representation format) that match the -f filter. If no -f was given, evaluate all correct dns packets. -u matchnamelist Count every occurence of every value of the matchname (for instance, count all packetsizes, see EXAMPLES in ldns-dpa(1) ). -ua For every matchname in -u, show the average value of all matches. Behaviour for match types that do not have an integer value is undefined. -uac For every matchname in -u, show the average number of times this value was encountered. -um number Only show the results from -u for values that occurred more than <number> times. -v level Set verbosity to level (1-5, 5 being the highest). Mostly used for debugging. -notip file Write packets that were not recognized as IP packets to file (as pcap data). -baddns file Write dns packets that were too mangled to parse to file (as pcap data). -version Show version and exit LIST AND MATCHES
A <matchnamelist> is a comma separated list of match names (use -s to see possible match names). A <expressionlist> is a comma separated list of expressions. An expression has the following form: <expr>: (<expr>) <expr> | <expr> <expr> & <expr> <match> <match>: <matchname> <operator> <value> <operator>: = equal to <value> != not equal to <value> > greater than <value> < lesser than <value> >= greater than or equal to <value> <= lesser than or equal to <value> ~= contains <value> See the -s option for possible matchnames, operators and values. EXAMPLES
ldns-dpa -u packetsize -p test.tr Count all different packetsizes in test.tr and show the precentages. ldns-dpa -f "edns=1&qr=0" -of edns.tr test.tr Filter out all edns enable queries in test.tr and put them in edns.tr ldns-dpa -f edns=1 -c tc=1 -u rcode test.tr For all edns packets, count the number of truncated packets and all their rcodes in test.tr. ldns-dpa -c tc=1,qr=0,qr=1,opcode=QUERY test.tr For all packets, count the number of truncated packets, the number of packets with qr=0, the number of packets with qr=1 and the number of queries in test.tr. ldns-dpa -u packetsize -ua test.tr Show all packet sizes and the average packet size per packet. ldns-dpa -u srcaddress -uac test.tr Show all packet source addresses and the average number of packets sent from this address. sudo tcpdump -i eth0 -s 0 -U -w - port 53 | ldns-dpa -f qr=0 -sf Print all query packets seen on the specified interface. AUTHOR
Written by Jelte Jansen for NLnetLabs. REPORTING BUGS
Report bugs to <jelte@nlnetlabs.nl>. COPYRIGHT
Copyright (C) 2005 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. 1 Nov 2005 dpa(1)
All times are GMT -4. The time now is 06:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy