|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to delete specific lines (2n+3 line, n=0,1,2...296) in a file?
Dear everyone,
I have a file with 900 lines (there is only numbers in one line, no string), I only need the lines 2+3n (n=0,1...296), i.e line 2, 5, 8, 11...888. I tried google but only the results such as how to delete all the odd lines or all the even lines with 'awk' command. Thanks in advance. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Assuming that you need those particular lines to be printed: Code:
awk '!((NR-2)%3)' file |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
You are great!!!
|
|
#4
|
|||
|
|||
|
Code:
$ sed -n '2~3p' file 2 5 8 Not sure this is POSIX compliant, though... |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
I hope this helps. bakunin |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete lines from a file which starts with a specific pattern | mady135 | Shell Programming and Scripting | 3 | 12-02-2010 04:10 AM |
| Delete all lines after a specific line ? | hakermania | Shell Programming and Scripting | 4 | 11-16-2010 12:41 PM |
| Delete specific lines from a file | itzz.me | Shell Programming and Scripting | 4 | 04-08-2009 04:12 PM |
| Delete lines prior to a specific date in a log file. | ahSher | Shell Programming and Scripting | 4 | 04-06-2009 05:19 AM |
| Delete specific lines in a text file | dniz | Programming | 9 | 08-08-2005 08:30 AM |
|
|