in reply to Re: grep command
in thread grep command
alternatives:tr ' ' '\n' < /tmp/hh | grep -c hello
Same technique as the tr/grep above, just in perl flavor:perl -lne '$ct += s/hello//g; END {print $ct}' /tmp/hh
Fun w/perlrun:perl -0040 -ne 'END {print "$x\n"} $x++ if /hello/' /tmp/hh
perl -Fhello -0777 -lane 'print $#F' /tmp/hh # shorter: perl -apFhello -0777e '$_=$#F' < /tmp/hh # with check for word boundry (e.g. to exclude "Othello" or mispelled +"cello") perl -apF'\bhello\b' -0777e '$_=$#F' < /tmp/hh
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: grep command
by shmem (Chancellor) on Jan 18, 2007 at 14:36 UTC |