From: James on
How to print head and tail (let's say 7 lines)?

JL
From: Bit Twister on
On Thu, 6 May 2010 14:18:50 -0700 (PDT), James wrote:
> How to print head and tail (let's say 7 lines)?

head -7 /some/filename ; tail -7 /same/filename

From: Ed Morton on
On 5/6/2010 4:30 PM, Bit Twister wrote:
> On Thu, 6 May 2010 14:18:50 -0700 (PDT), James wrote:
>> How to print head and tail (let's say 7 lines)?
>
> head -7 /some/filename ; tail -7 /same/filename
>

For the OP - if the file contains less than 14 lines do you want the middle ones
printed twice?

Ed.
From: Ed Morton on
On 5/7/2010 6:31 AM, Ed Morton wrote:
> On 5/6/2010 4:30 PM, Bit Twister wrote:
>> On Thu, 6 May 2010 14:18:50 -0700 (PDT), James wrote:
>>> How to print head and tail (let's say 7 lines)?
>>
>> head -7 /some/filename ; tail -7 /same/filename
>>
>
> For the OP - if the file contains less than 14 lines do you want the
> middle ones printed twice?
>
> Ed.

If the answer's no, then use:

awk '(NR<=7) || (NR>(nr-7))' nr=$(wc -l < file) file

Ed.
From: Dave Gibson on
Ed Morton <mortonspam(a)gmail.com> wrote:
> On 5/7/2010 6:31 AM, Ed Morton wrote:
>> On 5/6/2010 4:30 PM, Bit Twister wrote:
>>> On Thu, 6 May 2010 14:18:50 -0700 (PDT), James wrote:
>>>> How to print head and tail (let's say 7 lines)?
>>>
>>> head -7 /some/filename ; tail -7 /same/filename
>>>
>>
>> For the OP - if the file contains less than 14 lines do you want the
>> middle ones printed twice?
>
> If the answer's no, then use:
>
> awk '(NR<=7) || (NR>(nr-7))' nr=$(wc -l < file) file

{ head -n 7 ; tail -n 7 ; } < file
 |  Next  |  Last
Pages: 1 2
Prev: extract field
Next: replacing / with - in bash