Computing.Net > Forums > Unix > Delete all lines containing pattern

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete all lines containing pattern

Reply to Message Icon

Name: masayako
Date: January 16, 2003 at 11:44:32 Pacific
OS: unix
CPU/Ram: unix
Comment:

How to delete all lines containing pattern in vi?
I want to delete all lines containing the pattern "abc" in a file using vi. Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Frank
Date: January 17, 2003 at 02:18:41 Pacific
Reply:

Hi,

change to command mode by pressing the ESC key.
then
:/abc/ d

No Risk no Fun
Frank


0

Response Number 2
Name: Brent
Date: January 17, 2003 at 07:53:21 Pacific
Reply:

Here is a way


:g/abc/d

This will delete all instances of the pattern "abc"


0

Response Number 3
Name: masayako
Date: January 17, 2003 at 16:36:27 Pacific
Reply:

THANKS A LOT!

It works. ;)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Delete all lines containing pattern

sed - delete duplicate lines www.computing.net/answers/unix/sed-delete-duplicate-lines/7507.html

delete a line ina file using a serach pattern www.computing.net/answers/unix/delete-a-line-ina-file-using-a-serach-pattern/8462.html

Negate a Regular Expression? www.computing.net/answers/unix/negate-a-regular-expression/6515.html