You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by EJ Ciramella <ej...@upromise.com> on 2006/07/26 19:30:42 UTC
testing to see if a file contains a string
Is there some easy way to do this, or must I use <loadfile> then test to
see if the property contains the string I'm looking for?
I could have sworn there was an easy way to do this, but I can't find it
now...
Re: testing to see if a file contains a string
Posted by Dominique Devienne <dd...@gmail.com>.
Good catch. I had missed the introduction of this condition in 1.6.3.
Thanks, --DD
On 7/26/06, Andrew Goktepe <an...@gmail.com> wrote:
> You can also do this:
>
> <condition property="found.match">
> <isfileselected file="myfile.txt">
> <contains text="mystring" />
> </isfileselected>
> </condition>
>
> See http://ant.apache.org/manual/CoreTypes/selectors.html
>
> -Andrew
>
> On 7/26/06, Dominique Devienne <dd...@gmail.com> wrote:
> >
> > Use <loadfile> but with a nested <linercontains> filter, so the
> > property will be empty when the string is not found, which avoid
> > storing the whole file in the property. Then test whether the property
> > is empty or not with a condition. Wrap the whole thing in a macro for
> > convenience and expressiveness. --DD
> >
> > On 7/26/06, EJ Ciramella <ej...@upromise.com> wrote:
> > > Is there some easy way to do this, or must I use <loadfile> then test to
> > > see if the property contains the string I'm looking for?
> > >
> > > I could have sworn there was an easy way to do this, but I can't find it
> > > now...
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: testing to see if a file contains a string
Posted by Andrew Goktepe <an...@gmail.com>.
You can also do this:
<condition property="found.match">
<isfileselected file="myfile.txt">
<contains text="mystring" />
</isfileselected>
</condition>
See http://ant.apache.org/manual/CoreTypes/selectors.html
-Andrew
On 7/26/06, Dominique Devienne <dd...@gmail.com> wrote:
>
> Use <loadfile> but with a nested <linercontains> filter, so the
> property will be empty when the string is not found, which avoid
> storing the whole file in the property. Then test whether the property
> is empty or not with a condition. Wrap the whole thing in a macro for
> convenience and expressiveness. --DD
>
> On 7/26/06, EJ Ciramella <ej...@upromise.com> wrote:
> > Is there some easy way to do this, or must I use <loadfile> then test to
> > see if the property contains the string I'm looking for?
> >
> > I could have sworn there was an easy way to do this, but I can't find it
> > now...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: testing to see if a file contains a string
Posted by Dominique Devienne <dd...@gmail.com>.
Use <loadfile> but with a nested <linercontains> filter, so the
property will be empty when the string is not found, which avoid
storing the whole file in the property. Then test whether the property
is empty or not with a condition. Wrap the whole thing in a macro for
convenience and expressiveness. --DD
On 7/26/06, EJ Ciramella <ej...@upromise.com> wrote:
> Is there some easy way to do this, or must I use <loadfile> then test to
> see if the property contains the string I'm looking for?
>
> I could have sworn there was an easy way to do this, but I can't find it
> now...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org