• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to execute a grep command from Ant?

 
Johnson arthur
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

Can some one please help on how to execute a linux command like grep from ANT ?

Here is the command i want to run (grep = xyz.txt > abc.properties)

Can we use <exec task from ANT ? If so how to use it ?

Can i use something like this ?

<exec dir="${input}" command="grep = xyz.txt > abc.properties"/>

Please suggest!!

Thank you!!
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you want to use the <exec> task. Check out the docs for that task, it will give you some examples on how to invoke apps:
http://ant.apache.org/manual/Tasks/exec.html
Look specifically at the "output" property, that is how you would specify the "abc.properties" in your example.
Look at the <args> nested element, that is how you pass command line option to grep.
Finally, the "executable" property should be set to "grep", not to the full command line.

If you still have problems, feel free to post again, we'll be glad to help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic