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


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

Re: Read last expression in a file?

From Albert Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Read last expression in a file?
Date 2011-02-03 10:29 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iie01f$bjq$1@smc.vnet.net> (permalink)
References <ii5rh6$ff3$1@smc.vnet.net> <iibea5$nul$1@smc.vnet.net> <iibh70$ol8$1@smc.vnet.net>

Show all headers | View raw


Hi,
>>
>> 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?
>>

I've seen you have a version that works, but if you are interested in a
version which doesn't create an intermediate file here is something that
also works for me on Windows (with tail installed from the Resource Kit
Tools):

Import["!tail -0 \"" <> fname <> "\"", "Text"]

my filename did contain spaces, so I needed the enclosing "". Actually
to see what goes wrong it is useful to redirect stderr to stdout, so you
can see error messages, like here:

Import["!tail -0 \"" <> fname <> "\" 2>&1", "Text"]

once you have the command line running, you can of course also use
ReadList directly to perform the conversion to Mathematica expressions:

ReadList["!tail -0 \"" <> fname <> "\"", Expression]

hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous 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