[ale] Bash script question

Christopher Fowler cfowler at outpostsentinel.com
Thu May 15 08:20:23 EDT 2003


The problem is that bash isn't really made for this type of work.

> >comma_count=$(echo $line | tr -cd , | wc -c)

Sure, it may work above, but you are relying on external
programs such as tr and wc to do some work for you.  Nothing
I can tink of internal to bash will do this for you.  I've
ran into problems of compatibility issues in the past using
external commands to process strings.  



On Thu, May 15, 2003 at 07:41:46AM -0400, Geoffrey wrote:
> 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:
> >
> 
> 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
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list