On 06/07/12 12:43, Dominique Pellé wrote:
> On Thu, Jun 7, 2012 at 6:57 PM, Ben Fritz <fritzophrenic@gmail.com> wrote:
>> On Thursday, June 7, 2012 11:49:02 AM UTC-5, Dominique Pelle wrote:
>>> Marc Weber <marco-oweber@gmx.de> wrote:
>>>
>>>> forgett about vim, on linux just do:
>>>> tail -n +10 file.sql | head -n +10 > trimmed.sql
>>>
>>> Many people posted solutions with head and tail that don't work.
>>
>> Just curious...I've never used head or tail. But why won't they
>> work in this situation? This seems like exactly what they're
>> meant to accomplish; retrieving only a specific part of a file.
>
> Because tail outputs the last n lines of a file, but what user
> wanted is to remove the last lines. So unless you know the
> number of lines, you can't use tail. But perhaps someone
> can prove me wrong.
I think you're reading it backwards, as head/tail (at least GNU
versions; for other flavors, YMMV) allow for a "+" in front of the
number so
tail -n +20
chops off the first 19 lines in the file; similarly, "-" in front of
the number with head does all but the N last lines of the file. The
example above should likely read something like
tail -n +11 file.sql | head -n -10 > trimmed.sql
(using a "-" instead of a "+" for head and incrementing the starting
point on tail). There might be a fenceposting error there, but
that's the general gist.
-tim
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Thursday, June 7, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment