LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command to count all characters in file. (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-count-all-characters-in-file-798011/)

guif 03-26-2010 05:21 AM

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

PMP 03-26-2010 05:30 AM

cat <filename> | tr '\n' ' ' | tr '"' '\n' | wc -l

guif 03-26-2010 05:52 AM

thanks!

pwc101 03-26-2010 05:56 AM

Quote:

Originally Posted by PMP (Post 3913063)
cat <filename> | tr '\n' ' ' | tr '"' '\n' | wc -l

Or:
Code:

grep -o '"' input.txt | wc -l

w1k0 03-26-2010 08:44 AM

Quote:

Originally Posted by guif (Post 3913055)
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.


All times are GMT -5. The time now is 05:48 AM.