Multiple arguments on one column to filter another

Hello. I have a txt file like below. I would like to grab the first two names of the first columns from each group (0, 1, 2, 3...), so that it would look like the output table below. I believe I could use awk and head -n, but I am not sure how to put it together. If it helps, I don't necessarily need to know the group number, I just need the names in the output files. Any advice will be appreciated.

input file

name1 0
name2 0
name3 0
name4 0
name5 1
name6 1
name7 1
name8 2
name9 2

output file

name1 0
name2 0
name5 1
name6 1
name8 2
name9 2

Hi @moooo

When you post homework and any kind of school-related problem directed by an instructor, we expect all users to declare they are posting homework first.

Here are our rules:

https://community.unix.com/faq

Kindly review them prior to posting.

Thanks.

Hi.

This is not homework or school-related problem directed by an instructor.

Best.

It looks like homework to me.

There is no practical application for your question related to any normal task at work.

Is that right?

If not, what is the actual data and work application?

1 Like

Hi,

This is for my research unrelated to any coursework. I am new to coding as a first year and wanted to get help from the community.