Only printing certain rows

Hi,

I mainly work with altering columns with awk but now I encountered a problem with dealing with rows.

So what I want to do is only print rows that start with a specific name. For example:

## joe jack john
ty1 3 4
ty1 5 6
ty2 4 7
tym 5 6
tyz 7 9

Basically what I want to do is get rid of the row with ## and tym and tyz. So I only want to print ty1, and ty2

So the output will look like this:

ty1 3 4
ty1 5 6
ty2 4 7

phil

egrep 'ty[12]' < file

awk < filename '{if (($1=="ty1") || ($1 =="ty2")) print $0}'

Try...

sed -n '/^ty[12]/p' yourfile

Very similar to Corona688's version, except doing an exclusion instead of an inclusion.

## and tym and tyz
egrep -v "##|tym|tyz" < file