Unix Shell - Re: A SED Script to count the number of commas in each line and to

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > March 2006 > Re: A SED Script to count the number of commas in each line and to





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: A SED Script to count the number of commas in each line and to
Vino

2006-03-21, 8:05 am

pardha.saradhik@gmail.com wrote:
> Can any one helpme out in writing a sed script file that counts the
> number of commas in each line of a particular file and to print the
> number against the line in another or the same file..????
>
> I hav tried doing it..but failed...
>
> Plz help me as soon as possible..!!!
>
>
> Regards,
> Partha
>

What have you tried ? And where did you fail ?

See this. A non sed solution

while read line
do
echo -n "$line"
echo $line | tr -dc , | wc -c
done < input.txt

--.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com