Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 割|排序| uniq的蚂蚁等价物_Ant - Fatal编程技术网

Ant 割|排序| uniq的蚂蚁等价物

Ant 割|排序| uniq的蚂蚁等价物,ant,Ant,在Ant任务中,我设置了一个属性,它是一个文件列表。e、 g web/src/main/test/com/whatever/Ralph business/src/main/test/com/whatever/Alice web/src/main/test/com/whatever/Bob 我想从这个列表中提取子目录集。在bash中,我会: $ cat filename | cut -d'/' -f1 | sort | uniq business web 有没有一种方法可以在Ant宏中执行类似

在Ant任务中,我设置了一个属性,它是一个文件列表。e、 g

web/src/main/test/com/whatever/Ralph
business/src/main/test/com/whatever/Alice
web/src/main/test/com/whatever/Bob
我想从这个列表中提取子目录集。在bash中,我会:

$ cat filename | cut -d'/' -f1 | sort | uniq
business
web
有没有一种方法可以在Ant宏中执行类似的操作?它也需要在Windows上运行,因此
不是一个选项。

您可以使用带有的。也许是这样的:

<property name="list.of.files">
web/src/main/test/com/whatever/Ralph
business/src/main/test/com/whatever/Alice
web/src/main/test/com/whatever/Bob
</property>

<loadresource property="dirs">
    <string value="${list.of.files}" />
    <filterchain>
        <replaceregex pattern="/.*" replace="" />
        <sortfilter />
        <uniqfilter />
    </filterchain>
</loadresource>

<echo message="${dirs}" />

在Ant的旧版本中(不是对你问题的回答,而是一个提示-你可以用
sort-u
替换
sort | uniq
),谢谢。bash的魔力是永无止境的。那么使用资源(和同样的
filterchain
)呢?@matt:简单多了,谢谢。我总是忘记Ant资源的威力。
 [echo] business
 [echo] web

BUILD SUCCESSFUL