Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Number Question 2

Status
Not open for further replies.

lambros

Programmer
Oct 10, 2002
42
0
0
US
Hi,

Given the line number in a file; how is it possible to return the line?

L.
 
to get a SECOND line:

sed -n '2p' fileName.txt vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
My favorite if you want line 52 is....

head -52 file | tail -1

However if the file is only 50 lines long it will display the 50th line.
 
the best approach: vlad's 1.method -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Hi,

Just one more question;

for(ind in termsARR){
system(&quot;sed -n 'indp' log&quot;)
}

How can I do this? I'm trying to get the number from the array & assigning it to ind & using Vlads command from there.
 
# assuming this is part of an awk script:
#
for(ind in termsARR){
cmd=&quot;sed -n '&quot; ind &quot;p' log&quot;;
# system(cmd);
# OR
# cmd | getline myLine;
}
vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Vlad,

Thanks for all your help & quick responses, I'd have been some time figuring that out on my own.

L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top