Does anyone know how to use awk to print every 3rd line from the 1st line and including the 1st line?

1st
..
3rd
..
..
3rd
..
..
3rd

soemthing like this?

the closest I could get was below, but it dosn't go beyond the 3rd line.. any ideas? or sed maybe?

awk 'NR%3==1' file.txt
awk 'NR%3==0' file.txt

(or 1 or 2 depending on which actual lines you want)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.