* To extract a particular line(given by line number) from a file
@ 2003-03-28 18:35 Sadanapalli, Pradeep Kumar (MED, TCS)
2003-03-28 19:15 ` Tim Walberg
2003-03-28 19:26 ` Ashish V. Orpe
0 siblings, 2 replies; 4+ messages in thread
From: Sadanapalli, Pradeep Kumar (MED, TCS) @ 2003-03-28 18:35 UTC (permalink / raw)
To: linux-admin
Hi Friends,
I am running RedHat Linux 8.0. I want to do the following .
I have a file with several lines of data in it. I want to extract a line
I want from the file
and display the whole line of data. 'grep' searches only for patterns,as
I believe. I don't want to search for patterns.
I just directly want to extract the data by line numbers.For example, I
want to get the data in line number 5.
How can I do this? Is there any command to do this? Please help me. I
hope I am clear.
Thanks,
Pradeep
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: To extract a particular line(given by line number) from a file
2003-03-28 18:35 Sadanapalli, Pradeep Kumar (MED, TCS)
@ 2003-03-28 19:15 ` Tim Walberg
2003-03-28 19:26 ` Ashish V. Orpe
1 sibling, 0 replies; 4+ messages in thread
From: Tim Walberg @ 2003-03-28 19:15 UTC (permalink / raw)
To: Sadanapalli, Pradeep Kumar (MED, TCS); +Cc: linux-admin
[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]
tail +5 somefile | head -1
or
cat -n somefile | grep ' *5 '
or
sed -ne 5p somefile
or
...
On 03/28/2003 12:35 -0600, Sadanapalli, Pradeep Kumar (MED, TCS) wrote:
>> Hi Friends,
>> I am running RedHat Linux 8.0. I want to do the following .
>>
>> I have a file with several lines of data in it. I want to extract a line
>> I want from the file
>> and display the whole line of data. 'grep' searches only for patterns,as
>> I believe. I don't want to search for patterns.
>> I just directly want to extract the data by line numbers.For example, I
>> want to get the data in line number 5.
>>
>> How can I do this? Is there any command to do this? Please help me. I
>> hope I am clear.
>>
>> Thanks,
>> Pradeep
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
End of included message
--
+--------------------------+------------------------------+
| Tim Walberg | twalberg@mindspring.com |
| 830 Carriage Dr. | www.mindspring.com/~twalberg |
| Algonquin, IL 60102 | |
+--------------------------+------------------------------+
[-- Attachment #2: Type: application/pgp-signature, Size: 174 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: To extract a particular line(given by line number) from a file
@ 2003-03-28 19:20 jbrown105
0 siblings, 0 replies; 4+ messages in thread
From: jbrown105 @ 2003-03-28 19:20 UTC (permalink / raw)
To: linux-admin
Try looking at 'man head' or 'man tail'
Or ... why not just write a small Python or Perl app to do it for you?
jbrown
You said:
Hi Friends,
I am running RedHat Linux 8.0. I want to do the following .
I have a file with several lines of data in it. I want to extract a line
I want from the file
and display the whole line of data. 'grep' searches only for patterns,as
I believe. I don't want to search for patterns.
I just directly want to extract the data by line numbers.For example, I
want to get the data in line number 5.
How can I do this? Is there any command to do this? Please help me. I
hope I am clear.
Thanks,
Pradeep
--
http://www.fastmail.fm - Accessible with your email software
or over the web
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: To extract a particular line(given by line number) from a file
2003-03-28 18:35 Sadanapalli, Pradeep Kumar (MED, TCS)
2003-03-28 19:15 ` Tim Walberg
@ 2003-03-28 19:26 ` Ashish V. Orpe
1 sibling, 0 replies; 4+ messages in thread
From: Ashish V. Orpe @ 2003-03-28 19:26 UTC (permalink / raw)
To: Sadanapalli, Pradeep Kumar (MED, TCS); +Cc: linux-admin
awk 'NR == 5 {print $0}' somefile : this will extract the entire
fifth line
awk 'NR == 3, NR == 5 {print $0}' somefile : this will extract the
entire lines 3 to 5
awk 'NR == 3, NR == 5 {print $1,$2}' somefile : this will extract
the first and the second field from
lines 3 to 5
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-28 19:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-28 19:20 To extract a particular line(given by line number) from a file jbrown105
-- strict thread matches above, loose matches on Subject: below --
2003-03-28 18:35 Sadanapalli, Pradeep Kumar (MED, TCS)
2003-03-28 19:15 ` Tim Walberg
2003-03-28 19:26 ` Ashish V. Orpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).