It is currently Thu, 20 Jan 2022 04:46:37 GMT



 
Author Message
 . sed script: keep 1 line, delete next 7 lines
        a text file comme ca:

homer Simpson, Homer
line two
line three
line four
line five
line six
line seven

marge Simpson, Marge
line two
line three
line four
line five
line six
line seven

------------------------ eof -------------------

problem:
        keep the first line
        delete the next 7 lines (including the blank line)
        repeat

solution:
        sed "n;N;N;N;N;N;N;d" testfile

output:
homer Simpson, Homer        
marge Simpson, Marge        
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, ex seders moderator                                   sed u soon
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



 Thu, 08 May 2003 03:00:00 GMT   
 . sed script: keep 1 line, delete next 7 lines

news:G49Gp1.D9x.0.queen@torfree.net...

or

sed 2,8d testfile



 Fri, 09 May 2003 04:53:20 GMT   
 . sed script: keep 1 line, delete next 7 lines
In article <8v9epj$2q...@hermes.nz.eds.com>,
  "Peter Sundstrom" <peter.sundst...@eds.com> wrote:

Afraid not...sed 2,8d will not repeat indefinitely...

Sent via Deja.com http://www.deja.com/
Before you buy.



 Fri, 09 May 2003 03:00:00 GMT   
 . sed script: keep 1 line, delete next 7 lines

news:8vbc2p$aj9$1@nnrp1.deja.com...

Whoops.  I didn't read the question correctly.



 Sat, 10 May 2003 04:41:04 GMT   
 . sed script: keep 1 line, delete next 7 lines
Al Aab schrieb:

I would do this with awk:

awk -voffset=1 'NR==offset {print $0; offset += 8}' testfile

HTH

Dieter

--
Though this is a sick signature, it's still a significant signature.



 Sat, 10 May 2003 03:00:00 GMT   
 
   [ 5 post ] 

Similar Threads

1. SED: Converting 5 line script into 1 line script

2. sed want to print current line and start next cycle

3. find a string in a file then delete the next n lines

4. Remove a line if next line is blank

5. select line from file, and then the next line a week later

6. Get the current line and next 5 lines

7. Search file and print line + next line?

8. sed - delete first line of text file

9. Sed utility - deleting ind. lines of a record

10. Using awk/sed to delete a line.


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software