Darren
Darren

Reputation: 11011

How to use wildcards in ant shell command value?

Hi all I have the following task in ant:

<target name="clean">
    <exec executable="sudo">
        <arg value="rm"/>
        <arg value="-rf"/>
        <arg value="*"/>
    </exec>
</target>

However the * does not work, I can put a filename and it will work, but the * will not work. I need to only run this as sudo, is there a way to escape this so it works? It simply is ignoring the *.

Upvotes: 1

Views: 730

Answers (1)

M A
M A

Reputation: 72854

Try running as a shell script using the sh executable:

<exec executable="sh">
    <arg value="-c" />
    <arg value="sudo rm -rf *" />
</exec>

or

<exec executable="sh">
    <arg line="-c 'sudo rm -rf *'" />
</exec>

Upvotes: 4

Related Questions