LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-04-2005, 01:23 PM   #1
doctorwebbox
Member
 
Registered: Jun 2003
Location: Rotherham, South Yorkshire, England
Distribution: Debian
Posts: 117

Rep: Reputation: 15
Display line number n from a file


I am writing a bash script. Is there a command I can use that will return only line number n from a file?
 
Old 01-04-2005, 01:56 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
sed -n "linenumber p" file.txt
 
Old 01-05-2005, 02:06 PM   #3
doctorwebbox
Member
 
Registered: Jun 2003
Location: Rotherham, South Yorkshire, England
Distribution: Debian
Posts: 117

Original Poster
Rep: Reputation: 15
Just the job

Exactly what I was after. Thanks a lot. The sed manual is very difficult to understand. Do you know of a good howto?

Now I'm trying to find a way to return the last 3 characters of the string and the first.
 
  


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
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
Getting Line Number in Error Log File kushalkoolwal Programming 6 10-17-2005 12:50 PM
Print line number X of a file (in shell) rheza Programming 4 01-04-2005 05:55 PM
Count number of line in a file. philipina Programming 7 03-18-2004 05:04 PM
Display/Read line 'N' in a text file using script ganninu Linux - Newbie 2 10-13-2003 05:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 PM.

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