LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2010, 07:03 AM   #1
joob77
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Rep: Reputation: 0
count words with comma as separator


Hi all,

I'm trying to count words in a text file that has a comma as separator. I know that I must user wc -w, but wc uses space as a separator.

Does anyone know how to do this?

Thanks,
Joost
 
Old 02-16-2010, 07:14 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

This works:
Code:
cat file | tr ',' ' ' | wc -w
Hope this helps.
 
1 members found this post helpful.
Old 02-17-2010, 02:37 AM   #3
joob77
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Original Poster
Rep: Reputation: 0
this helps!

Thanks a lot.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
count lines and words lipun4u Linux - Newbie 2 02-15-2010 02:39 AM
Removing white spaces between words and joining the words in a given format Priyabio Linux - General 4 08-20-2009 08:42 AM
How to delete Comma in a comma separated file with double quotes as quote character pklcnu Linux - Newbie 2 03-24-2009 06:50 PM
Bash command separator/arguments separator reverse Programming 11 12-02-2007 10:21 PM
How to count occurrences of unique words in a file beeblequix Linux - General 3 01-14-2007 04:47 PM


All times are GMT -5. The time now is 09:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration