Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15834

Re: Read last expression in a file?

From Chris Degnen <degnen@cwgsy.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Read last expression in a file?
Date 2011-02-02 12:03 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iibh70$ol8$1@smc.vnet.net> (permalink)
References <ii5rh6$ff3$1@smc.vnet.net> <iibea5$nul$1@smc.vnet.net>

Show all headers | View raw


Actually this works fine:

Run["tail -0 outputfile > tail.txt"];
Import["tail.txt"]



On Feb 2, 11:14 am, Chris Degnen <deg...@cwgsy.net> wrote:
> You can find a Windows (XP) version of tail here:http://malektips.com/xp_=
dos_0001.html
>
> (from the Windows Server 2003 Resource Kit Tools).
>
> While 'tail outputfile' works on the command line, and the output
> (last line -0) can be redirected to tail.txt like so:
> tail -0 outputfile > tail.txt
>
> the redirection doesn't seem to work when run from Mathematica. I.e.
> using
>
> Run["tail -0 outputfile > tail.txt];
> Import["tail.txt]
>
> I also tried your version: ReadList["!tail outputfile", Expression]
> but no luck with that either.
>
> Any suggestions, anyone?
>
> On Jan 31, 8:23 am, Heike Gramberg <heike.gramb...@gmail.com> wrote:
>
>
>
> > If you are working on unix/linux/os x and your output file contains one=
 expression per line, you could use something like
>
> > ReadList["!tail outputfile", Expression]
>
> > where outputfile is the name of your output file. This basically calls =
the external command tail which is a program on unix/linux that displays th=
e last few lines of a file.
>
> > I'm not familiar with windows so I don't what the windows equivalent of=
 tail would be.
>
> > Heike.
>
> > On 30 Jan 2011, at 00:43, Ramiro wrote:
>
> > > Hello,
>
> > > I wrote a program that generates a lot of Mathematica output.
>
> > > Now I need to restart it using the very last expression of such outpu=
t
> > > as the new input.   However, I can't find a way to only read the la=
st
> > > expression in a file, something like a Read that would start at the
> > > end.  It would be too time consuming and perhaps not enough memory =
in
> > > my computer to read the entire file.
>
> > > Any suggestions?
>
> > > Thanks,
> > > Ramiro- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Read last expression in a file? Heike Gramberg <heike.gramberg@gmail.com> - 2011-01-31 08:23 +0000
  Re: Read last expression in a file? Chris Degnen <degnen@cwgsy.net> - 2011-02-02 11:14 +0000
    Re: Read last expression in a file? Chris Degnen <degnen@cwgsy.net> - 2011-02-02 12:03 +0000
      Re: Read last expression in a file? Albert Retey <awnl@gmx-topmail.de> - 2011-02-03 10:29 +0000

csiph-web