The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cutting specific lines from a file pathanjalireddy Shell Programming and Scripting 15 06-04-2009 01:32 AM
need help cutting consecutive lines with sed or awk raghin Shell Programming and Scripting 2 06-04-2008 04:59 AM
grab next consecutive line or lines wisher115 Shell Programming and Scripting 1 12-07-2006 08:01 AM
Appending Consecutive lines pondlife Shell Programming and Scripting 8 08-13-2004 05:36 AM
Cutting lines out using sed I presume. cfoxwell UNIX for Dummies Questions & Answers 5 01-08-2002 12:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-18-2002
Vishnu Vishnu is offline
Registered User
  
 

Join Date: Aug 2002
Location: Marlboro, MA
Posts: 114
Cutting n consecutive lines from a file...

Hi,

I have this problem of separating 10 consecutive lines from a file, say starting from 21 to 30... I have used a filter like this..

head -n 30 myfile | tail -n 10

Is there a simpler way than this?
  #2 (permalink)  
Old 10-18-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
Are you trying to do this in a script or as you view the file. Are you trying to save the text to a file?

If in an file editing with vi, do this.

vi filename

:21,30w newfile.out

That will save out the 10 lines in question.

If you are trying to script this, you can search this forum for capturing lines of text from a file. I have seen at least one thread before in the last 6 months.

  #3 (permalink)  
Old 10-18-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
sed -n '21,30p' < myfile
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0