Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
245 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 2000 total points
ID: 39176796
sed -ri '/(Houston|Dallas|Austin)/!d' file

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

824 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