Solved

How do I write a sed command to delete a row if it doesn't contain certain words?

Posted on 2013-05-18
1
232 Views
Last Modified: 2013-05-18
Hi
How do I write a sed command to delete a row if it doesn't contain certain words?

ie.
If the line doesn't contain "Houston", "Dallas", or "Austin", I wan to delete the line

Thanks
Jamie
0
Comment
Question by:jamie_lynn
1 Comment
 
LVL 21

Accepted Solution

by:
Mazdajai earned 500 total points
ID: 39176796
sed -ri '/(Houston|Dallas|Austin)/!d' file

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now