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 the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-27-2006
gopskrish gopskrish is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 26
delete string in a text file leaving the first occurrence

Hi,

How can i delete the second and subsequent occurrence of a particular string from a file ?

eg) test.txt
cattle
bat
battle
mat
matter
cattle
cattle

my output file should be

cattle
bat
battle
mat
matter

I am new to unix and your advice is greatly appreciated.

Thanks in advance,
gops