02-22-05 10:52 PM
On Tue, 22 Feb 2005 07:03:51 -0800, mshetty wrote:
> Hi,
>
> How do I find the count of a specific character in a line?
>
> For eg: If my line is "|a |a |a |b |c"
>
> then looking for "a" should return 3.
>
> Is there a way to directly obtain this?
For a single character, use 'tr' to remove everything else, and then use
either wc or awk to count what is left.
echo "|a |a |a |b |c" | tr -c -d a | wc -c
[ Post a follow-up to this message ]
|