Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete line if contains pattern

Status
Not open for further replies.

dbase77

Technical User
Apr 23, 2002
591
IE
Hi,

How do I go about deleting any lines that contain pattern on the first 3 characters or maybe first 5 characters? Example file contains:

.
.
How much does it cost?
Where are you now, How?
Is this correct?
How old are you?
How are you?
.
.

I want to remove "How" lines and "Is" line for example. I be able to use sed or awk but they both search the whole line. I just want to search for the first 3 chars on each line.

Thanks.
 
You can just tie your regexp to the beginning of the line using ^, e.g. /^(How|Is)/ should work in awk.

Annihilannic.
 
Yes, that what I forgot. The "^" sign.



Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top