ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Reason" <>
Subject RE: [solution] Need help using exec to do "ls -rt1 | tail -1"
Date Mon, 07 Apr 2003 22:13:02 GMT

You would think that'd work, but it doesn't.

Trust me - I've done them both.

Ant needs to pass a string with quotes in it to the sh executable.


-----Original Message-----
From: Dominique Devienne [] 
Sent: Monday, April 07, 2003 12:31 PM
To: 'Ant Users List'
Subject: RE: [solution] Need help using exec to do "ls -rt1 | tail -1"

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).


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message