How do you specific lines in a file? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

How do you specific lines in a file?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-22-2005
hedgehog001 hedgehog001 is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 22 August 2005, 10:21 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
How do you specific lines in a file?

I'm looking to show specific lines (eg. 20 through 40) of a series of files in the directory. How do I do this?
Sponsored Links
    #2  
Old 08-22-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
You could use sed. I believe the syntax is as follows:

Code:
sed -n '20,40p' file_name

For files in a directory:

Code:
cd directory_where_files_are
for file_name in *; do
sed -n '20,40p' file_name
done

Sponsored Links
    #3  
Old 08-23-2005
Ygor's Avatar
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 2 May 2014, 7:14 AM EDT
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 112 Times in 98 Posts
Try..
Code:
awk 'FNR>=20 && FNR<=40' file*

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
deleting specific lines in a file asanchez Shell Programming and Scripting 5 07-27-2011 03:41 AM
Extracting specific lines of data from a file and related lines of data based on a grep value range? Wynner Shell Programming and Scripting 3 05-18-2011 11:35 AM
Substitute specific lines with lines from another file rahmathulla Shell Programming and Scripting 1 01-11-2009 10:45 AM
how to display specific lines of a specific file raidkridley UNIX for Dummies Questions & Answers 2 10-15-2008 02:46 PM
overwrite specific lines in a file csecnarf Shell Programming and Scripting 7 05-13-2008 11:01 AM



All times are GMT -4. The time now is 04:38 PM.