|
Home > Archive > Unix Shell > November 2006 > Read multiple lines from a text file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Read multiple lines from a text file
|
|
|
| Hi,
Could you please tell me how to read multiple lines from a text
file at a time.
>$ cat ABC.txt
this is line 1
this is line 2
this is line 3
this is line 4
this is line 5
this is line 6
this is line 7
this is line 8
this is line 9
>$
How to read or print on the screen multiple line (from line 4 to line
6) by using sed or awk ?
Thanks in Advance,
Dattu
| |
| Chris F.A. Johnson 2006-11-24, 7:24 am |
| On 2006-11-24, Dattu wrote:
> Hi,
> Could you please tell me how to read multiple lines from a text
> file at a time.
>
> this is line 1
> this is line 2
> this is line 3
> this is line 4
> this is line 5
> this is line 6
> this is line 7
> this is line 8
> this is line 9
>
> How to read or print on the screen multiple line (from line 4 to line
> 6) by using sed or awk ?
sed -n 4,6p ABC.txt
awk 'NR == 4, NR == 6' ABC.txt
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
|
|
|
|
|