LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-28-2005, 04:44 AM   #1
minil
Member
 
Registered: Dec 2004
Location: Bangalore, India
Distribution: Fedora 2
Posts: 74

Rep: Reputation: 15
command or shell script to print line range from file


Hi
i need a script or command to print range of line from a specified file

For eg.
$ [command] 10 20 file

This should display line numbers from 10 to 20 from the file.
Its urgent..
Thanks in advance.

regards
Minil
 
Old 12-28-2005, 04:47 AM   #2
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
Code:
sed -n '10,20p' <filename>
 
Old 12-28-2005, 07:16 AM   #3
vetrimani
LQ Newbie
 
Registered: Dec 2005
Posts: 8

Rep: Reputation: 0
you can use awk 'NR>=10&&NR<=20' file
 
Old 12-28-2005, 08:05 AM   #4
minil
Member
 
Registered: Dec 2004
Location: Bangalore, India
Distribution: Fedora 2
Posts: 74

Original Poster
Rep: Reputation: 15
Its nice..

thank u ..for your reply..
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 PM
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 09:24 AM
How to execute a command line in a shell script orgazmo Programming 5 05-09-2005 09:16 AM
Print line number X of a file (in shell) rheza Programming 4 01-04-2005 05:55 PM
Shell Script to read 500files from the command line saravanan1979 Programming 1 09-22-2004 09:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration