Re: delete last line



On Thu, Jan 10, 2008, Jean-Pierre Radley wrote:
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

In place edit using the ex editor (would probably work with ed as well.

ex - filename <<DONE
$d
w
q
DONE

Using the gnu shtool program:

shtool subst -e '$d' filename

Bill
--
INTERNET: bill@xxxxxxxxxxxxx Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676

The only freedom which deserves the name, is that of pursuing our own good
in our own way, so long as we do not attempt to deprive others of theirs,
or impede their efforts to obtain it. -- John Stuart Mill, 1859
.



Relevant Pages

  • Re: Changing Uppercase filenames into Lowercase
    ... uppercase filename to a lowercase filename, ... foundfile = f$searchcommand line. ... Based on a command procedure by Willem Grooters which was ...
    (comp.os.vms)
  • Re: Pass command line file name parameter
    ... Then the document class has a copy of the filename, ... No need to access the original command line at all. ... want the user to see all the labels as they would be printed. ... filename or any other variable of your CWinApp class. ...
    (microsoft.public.vc.mfc)
  • Re: CStdioFile::Open gives error "No error occurred"
    ... I would avoid GetErrorMessage and just use FormatMessage on the error code itself, ... presume this is *not* the filename you planned to open, so why are you using m_lpCmdLine? ... there is a serious question here as to whether or not the command line has any ... Use the debugger, it is a very useful tool. ...
    (microsoft.public.vc.mfc)
  • Re: Cannot delete directory
    ... "Glenn" wrote in message ... > in a command window. ... >>window is a "normal" window. ... >>be a valid 8.3 filename - even if it has somehow been ...
    (microsoft.public.win2000.file_system)
  • Re: command line input and output
    ... Alternatively the first argument was a legal filename but it didn't exist, ... If there were no command line ... Microsoft Powerstation 4.0. ... qomputing dot demon dot co dot uk-- ...
    (comp.lang.fortran)