The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 12-09-2004
druuna druuna is offline
Registered User
 

Join Date: Feb 2004
Location: netherlands
Posts: 42
Something like this maybe:

#!/bin/bash

SEARCHSTRING="foo"

sed "s/${SEARCHSTRING}/${SEARCHSTRING}\n/g" infile | \
grep ${SEARCHSTRING} | wc -l


Did 2 quick tries. One on a text file an d the second on a script with a more complex searchstring. Both worked.

Hope this helps.
__________________

The dead stay dead and the living only wait to join them........
Reply With Quote