The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Counting occurence of a particular character on each line hey_mak UNIX for Dummies Questions & Answers 4 06-26-2008 06:56 AM
First occurence of character in a file dhanamurthy Shell Programming and Scripting 6 05-13-2008 01:56 AM
first occurence and line number mercuryshipzz Shell Programming and Scripting 9 01-22-2008 07:42 PM
search& count for the occurence of a word skoppana UNIX for Dummies Questions & Answers 1 11-09-2007 05:07 PM
Count the number of occurence of perticular word from file rinku Shell Programming and Scripting 40 08-10-2007 08:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2008
sumit207 sumit207 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 10
Smile 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.
  #2 (permalink)  
Old 11-26-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926

Code:
awk -F, '{print NF-1}' infile


Code:
perl -nle'print tr/,//' infile

  #3 (permalink)  
Old 11-26-2008
sumit207 sumit207 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 10
Thanx for the solution.
  #4 (permalink)  
Old 02-09-2009
Dipali Dipali is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
I have csv data with spaces like below:

1,number one,first
2,number two second
3, number three, third

i want to count no. of commas in each line.
how to achieve that.
  #5 (permalink)  
Old 02-09-2009
angheloko's Avatar
angheloko angheloko is offline
Registered User
  
 

Join Date: Jul 2008
Location: Philippines
Posts: 125
Quote:
Originally Posted by Dipali View Post
I have csv data with spaces like below:

1,number one,first
2,number two second
3, number three, third

i want to count no. of commas in each line.
how to achieve that.
Ok...You did read previous posts right?
  #6 (permalink)  
Old 02-09-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
I opened a new thread with the last post since it's quite different than the original question in this thread.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0