Re: string occurrences
On Sat, Jan 23, 2010 at 04:11:03PM -0600, Brian Ryans wrote:
> Quoting roberto on 2010-01-23 15:33:53:
> > is there any linux built-in utilities to count how many times a string
> > occur in a text file ?
>
> I don't know of any actual utilities to do so, but there's a handy
> little pipeline that I use as a generic string-counter that, so far,
> works for all files I've tried, printable or not.
>
> $ strings $yourFile | grep -oe '$yourString' | wc -l
It's a bit nitpicky, but you could save a step and a few keystrokes with:
$ strings $yourFile | grep -oce '$yourString'
Cheers,
--
Eric Gerlach, Network Administrator
Federation of Students
University of Waterloo
p: (519) 888-4567 x36329
e: egerlach@feds.uwaterloo.ca
Reply to: