Remove lines from file

Hey Gang-

I have a list of servers. I want to exclude servers that begin with and end with certain characters. Is there an easy command to do this?

Example

wvm1234dev
wvm1234pro
uvm1122dev
uvm1122bku
uvm1344dev

I want to exclude any lines that start with "wvm" OR "uvm" AND end with "dev".

Thoughts, issues, concerns? LOL
Thanks!!!

Try..

awk '(!/^wvm/ || !/^uvm/) && !/dev$/ {print}' file

Sweet... that works! I tried to add another condition to the second set... but it didn't work. What if I want to exclude ones that start with wvm or uvm, and end with dev or pdv?

I tried

awk '(!/^wvm/ || !/^uvm/) && (!/dev$/ || !/pdv$/) {print}' file

What should be the required output?

Did you try this?

awk '(!/^wvm/ || !/^uvm/) && (!/dev$/ || !/pdv$/ ) {print}' file

Another way using egrep...

grep -vE "^(u|w)vm.*(pdv|dev)$" file

Doesn't seem to work with the extra variable. Here's my text data..

uvm1234bdc
uvm1234pdv
uvm3131pdv
wvm1122pdv
wvm3312cdc
nap1121bdc
nap1345pdv
wvm3333dev

It returns all of them without filtering any out. :frowning:

---------- Post updated at 11:08 AM ---------- Previous update was at 11:06 AM ----------

The grep command worked too. Thanks shamrock!

awk '{if (match($1,"uvm") == 0 && match($1, "dev") == 0){print $0}}' File

The grep would be the usual way of doing this. Awk would be:

awk '!/^[uw]vm.*(pdv|dev)$/'