On Thu, Nov 20, 2008 at 3:06 PM, Vamsi Krishna
<[EMAIL PROTECTED]> wrote:
>
> hi all,
>
> i need to grep a word count from a text file and i want to display the
> count.
> i need all the above in a rake file , i tried it by using
>
> today_count= system("grep -R 'time' oct_10.txt | grep -R 'hi' | wc
> -l")
> puts "today count is :#{today_count}"
>
> but today_count returns 'true' instead of count.
normal, system() return true or false only, not stdout...
you can use ``, popen, or code that in ruby.
today_count = File.open('oct_10.txt').grep('time').grep('hi').size
(not tested)
--
Gabriel Laskar <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---