LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-26-2010, 05:21 AM   #1
guif
LQ Newbie
 
Registered: Dec 2008
Posts: 24

Rep: Reputation: 15
Command to count all characters in file.


hi!
anybody know and command to count any characters in file?
I would like to know the total number of character " (quote) in file.
My idea is to check if in a script the total number of this character is pair.

thanks
 
Old 03-26-2010, 05:30 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
cat <filename> | tr '\n' ' ' | tr '"' '\n' | wc -l
 
Old 03-26-2010, 05:52 AM   #3
guif
LQ Newbie
 
Registered: Dec 2008
Posts: 24

Original Poster
Rep: Reputation: 15
thanks!
 
Old 03-26-2010, 05:56 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by PMP View Post
cat <filename> | tr '\n' ' ' | tr '"' '\n' | wc -l
Or:
Code:
grep -o '"' input.txt | wc -l
 
1 members found this post helpful.
Old 03-26-2010, 08:44 AM   #5
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by guif View Post
My idea is to check if in a script the total number of this character is pair.
Positive results of these tests don't assure that all quote characters are paired. Assuming that you have script with two unpaired quotes the tests display even number of quote characters.
 
  


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
Trying to identify file types(command line arguments) and count how many there are jdwalk Linux - Newbie 5 02-20-2010 03:51 PM
Need help in word count command grunge_1 Linux - General 4 03-20-2009 04:01 AM
how to delete last number/word of a file and incude file count at the end of the chennaiguy Linux - Newbie 2 02-18-2008 09:08 PM
characters count in a string powah Programming 3 07-19-2007 02:03 PM
command to count how many lines in a file? dr_zayus69 Linux - Software 3 01-06-2005 10:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:19 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