Re: delete last line



Jean-Pierre Radley typed (on Fri, Jan 11, 2008 at 12:25:38PM -0500):
| Jeff Hyman typed (on Fri, Jan 11, 2008 at 11:20:40AM -0500):
| | Jean-Pierre Radley typed (on Thu, Jan 10, 2008 at 05:55:06PM -0500):
| | | pablo typed (on Thu, Jan 10, 2008 at 02:03:03PM -0800):
| | | | how can I delete the last line of a text file from the command line ?
| | | |
| | | | I mean only last line
| | |
| | | sed '$d' in.file > out.file
| | |
| | | --
| | | JP
| |
| | Well... now I'm curious.
| |
| | How would you delete ONLY the next-to-last line,
| | leaving the previous very last line to replace
| | the space where the next-to-last line was just
| | removed?
|
| Badly phrased question. If you remove a line, there is no "space left
| behind". There would only be a "space left behind" if you deleted the
| just the line's visible contents, AKA as blanking the line. When one
| says remove, one means removing the 'newline' as well, so that there's
| nothing left at all.
|
| In any case, what you meant to do would want a small modification to what
| Bill just posted:
|
| ex - filename <<DONE
| $
| -
| w
| q
| DONE
|

JP,
We've know each other for a long long time. If you were able
to "fix" me from making all those typos, confusing explainations,
questionable questions, etc, I would have had a sex change and tried
to marry you long ago. Please don't mention this to Jane. For those
of that don't know me, I'm a mans man, so don't even think about what
your thinking <g>.

The one hyphen is the difference between what you posted above
and what Bill posted. So, what would be the case if:
###---------------------------------------------------
ex - filename <<DONE
$
- Removes next to last line (from previous post)
- Add another hyphen to rm the next-to-next last line ?
Add 5 more to remove another 5 lines ?
w
q
DONE
###---------------------------------------------------
IOW: What if one wanted to remove the last 6 lines, but
keep the very last line? I understand if your to busy,
but I find this issue really interesting for some reason.
###---------------------------------------------------

- Jeff H

.



Relevant Pages

  • Re: MS really couldnt give to sh*ts about its individual customers and small businesses!
    ... our information at this time leads us to believe that this is ... MS is leaving the fix to HP. ... leaving the ActiveX fiasco to be fixed by web developers. ...
    (microsoft.public.windowsxp.general)
  • [PATCH 3/3] block/md: fix md autodetection
    ... rescan_partitions() leaving md autodetect unable to see partitions. ... Fix it. ... Oops, I forgot 2/3 in the subject of the second patch. ...
    (Linux-Kernel)
  • Re: from 5.4-PRERELEASE -> 5.3-RELEASE-p5 error?
    ... On Fri, 11 Mar 2005, Bashar wrote: ... >>You're leaving out important details, like what you did after you cvsup'd. ... I'm not sure how to fix you at this point ... ... You should also file a bug with the cpanel folks and have them handle the ...
    (freebsd-stable)
  • Re: Delete first few cell characters
    ... Assuming data is in column A ... Copy block of results and Paste Special>Values to "fix" as opposed to ... leaving as formulae ... I would be grateful if you could provide me the code to do just this. ...
    (microsoft.public.excel.misc)
  • Re: Understanding a simple C program
    ... whether or not a newline is needed is implementation defined. ... The standard doesn't require ... Is an implementation allowed to say that the behavior of leaving off ... Though if the documentation made a more realistic statement that the ...
    (comp.lang.c)