Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 6459  / 2 Years ago, wed, july 13, 2022, 10:07:26

I have done it with simple loop to count and print through.. How can I do it in bash scripting with program such as sed,awk ?


More From » sed

 Answers
2

Something like this:



awk 'NR % 3 == 2'



Test





sh-3.2$ more test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15



Result




sh-3.2$ awk 'NR % 3 == 2' < test
2
5
8
11
14

[#31646] Thursday, July 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
percol

Total Points: 493
Total Questions: 116
Total Answers: 107

Location: Taiwan
Member since Mon, Sep 6, 2021
3 Years ago
;