see a specific line in 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 !!

see a specific line in file

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-30-2007
zivsegal
Guest
 
Posts: n/a
Bug see a specific line in file

Hi,

In need to see a specific line in a file ,
I work in tcsh sell,
some kind of
cat -line <XXX> templet_file

Thanks,
Ziv
Sponsored Links
    #2  
Old 10-30-2007
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
 
Join Date: Jun 2006
Last Activity: 1 December 2008, 8:39 AM EST
Location: Madrid (Spain)
Posts: 531
Thanks: 0
Thanked 1 Time in 1 Post
for instance, line #10 of file.txt:

Code:
head -10 file.txt|tail -1

Sponsored Links
    #3  
Old 10-30-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Advisor  
Full Time Dad
 
Join Date: Sep 2006
Last Activity: 4 April 2014, 3:58 AM EDT
Location: Rossem, Tazenda
Posts: 1,211
Thanks: 6
Thanked 17 Times in 16 Posts
if your cat command supports -n option:
Code:
cat -n wordfile | grep "^ *5"

where 5 is line number to print
    #4  
Old 10-30-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 5 July 2014, 11:14 AM EDT
Location: classification algos
Posts: 3,203
Thanks: 19
Thanked 30 Times in 27 Posts

Code:
awk ' NR == 5 ' filename


Code:
sed -n '5p' filename

Sponsored Links
    #5  
Old 10-30-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 29 October 2014, 9:43 AM EDT
Location: Варна, България / Milano, Italia
Posts: 5,675
Thanks: 184
Thanked 620 Times in 578 Posts
For large files:


Code:
awk 'FNR == 5 { print; exit }' filename


Code:
sed '5q;d' filename

Sponsored Links
    #6  
Old 04-23-2009
pank29 pank29 is offline
Registered User
 
Join Date: Apr 2009
Last Activity: 3 July 2009, 2:25 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Hi All,
Currently i have to write a script.
For which i need to cut a block from .txt file.
I know the specific word that starts the block and ends the block.
Can we do it in shell scripting..?
Please suggest....
Sponsored Links
    #7  
Old 04-23-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 31 October 2014, 2:54 PM EDT
Location: Foxborough, MA
Posts: 7,667
Thanks: 152
Thanked 586 Times in 551 Posts
Take a look at a sed1liners
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
how read specific line in a file and write it in a new text file? vel4ever Shell Programming and Scripting 6 02-15-2012 06:40 AM
printing specific line from a file. siba.s.nayak UNIX for Advanced & Expert Users 2 09-10-2009 04:13 PM
Change Specific Line of a File msb65 UNIX for Dummies Questions & Answers 10 08-20-2008 10:18 PM
Add a line to a specific spot in a file d__browne UNIX for Advanced & Expert Users 6 12-07-2006 06:52 AM
reading specific line from file cool_boss2121 Shell Programming and Scripting 10 04-26-2005 09:05 PM



All times are GMT -4. The time now is 03:10 PM.