Michael Tewner wrote:
> Is there a reason that there isn't a tool that prints one or more lines
> from within a file?
>
> For years, everyone has been doing this with ` head | tail `
>
> ...or is there a program that does this already?
Brian Dessent wrote:
> seq 1 50 | sed -n 3,25p
> sed 1 50 | sed -n 11,+10p # gnu sed only
And fancy stuff is available too.
seq 1 50 | sed -n '3,4p;10p;12,14p'
Or use awk as it is one of the standard utilities as well. (NR is the
number of records (lines) seen so far.)
seq 1 50 | awk '5 <= NR && NR <= 9'
But you can really get fancy with it such as printing the odd lines
between 5 and 30.
seq 1 50 | awk '5 <= NR && NR < 30 { if (NR % 2) print; }'
Bob
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils