[ale] Bash script question

Geoffrey esoteric at 3times25.net
Thu May 15 07:41:46 EDT 2003


Byron A Jeff wrote:
>>Is there a utility that I can run from bash that I can use to determine 
>>the number of times a certain character appears in a line?
>>
>>Example - I want to determine the number of times a comma (,) appears in 
>>the line:
>>
>>Field1,Field2,Field3,
>>
>>Yes, it can be done from Perl, but I would like to do this from bash.
> 
> 
> bash presumes to have all of the standard unix commands available. My entry is:
> 
> comma_count=$(echo $line | tr -cd , | wc -c)

Sweet, gotta love UNIX tools. :)

> 
> where the variable line has the Field1,... line in it.
> 
> BAJ
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 
> 

-- 
Until later: Geoffrey		esoteric at 3times25.net

The latest, most widespread virus?  Microsoft end user agreement.
Think about it...

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list