MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: awk in mathematica

  • To: mathgroup at
  • Subject: [mg3569] Re: awk in mathematica
  • From: econrad at (Eric Conrad)
  • Date: Mon, 25 Mar 1996 21:34:21 -0500
  • Organization: Department of Mathematics, The Ohio State University
  • Sender: owner-wri-mathgroup at

In article <4itoos$v8 at>,
Luc Derrendinger  <flocsim at> wrote:
>Dear Mathematica users
>Could you tell me how to use and/or implement the programming
>language AWK into mathematica ?
>Thank you for your help,
>                               Luc

You can prepare the awk script either ahead of time using a text editor
or during the Mathematica session using OpenWrite[], WriteString[],
and Close[].  The data file could likewise be prepared.  To run awk
from within Mathematica, use the Run[] command.

Here is an example under the Unix operating system:

Script started on Fri Mar 22 10:10:03 1996
> cat foo.awk
BEGIN		{print "start " FILENAME;}
$1 == "foo"	{print $2;}
END		{print "end " FILENAME;}
> math
Mathematica 2.2 for SPARC
Copyright 1988-94 Wolfram Research, Inc.
 -- Open Look graphics initialized --

In[1]:= fp=OpenWrite[""]; WriteString[fp, "foo 1 2 3\n"];
In[2]:= WriteString[fp, "bar 4 5 6\n"]; Close[fp];
In[3]:= Run["cat"]
foo 1 2 3
bar 4 5 6
Out[3]= 0
In[4]:= Run ["awk -f foo.awk"]
Out[4]= 0
In[5]:= ^D
> ^D

script done on Fri Mar 22 10:12:26 1996

Good luck,


  • Prev by Date: Re: Mathematica on Solaris 2.x
  • Next by Date: Showing infinite values in Grafics ??
  • Previous by thread: awk in mathematica
  • Next by thread: mathematica-macppp conflict