ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: [solution] Need help using exec to do "ls -rt1 | tail -1"
Date Mon, 07 Apr 2003 19:30:40 GMT
This should also work, and the quoting's done by Ant:

<exec dir="${sourcedir}" executable="sh" ...>
  <arg value="-c"/>
  <arg value="ls -rt1 | tail -1"/>

It's a bit easier on the eyes IMHO. --DD

-----Original Message-----
From: Matt Reason [] 
Sent: Monday, April 07, 2003 2:28 PM
To: Ant Users List
Subject: [solution] Need help using exec to do "ls -rt1 | tail -1"

Thanks to everyone for all the input.  I had no idea the pipe was
interpreted by the shell.

With that in mind, I got it to work.  Here is how to do it:

<target name="getNewest">
        <exec dir="${sourcedir}" executable="sh"
                <arg line="-c &quot;ls -rt1 | tail -1&quot;"/>
        <echo message="The newest file in ${sourcedir} is:

NOTE: You have to put the actual command in quotes (&quot).


View raw message