使用交错的、重复的参数名称和参数值构建命令
build command with interleaved, repeated parameter names and argument values
我正在使用名为 ROBOT 的工具合并 ontology 个文件:http://robot.obolibrary.org/merge
它有一个带通配符的 --inputs
参数,但这在我的环境中似乎不起作用(Windows 10 中的 GitBash)。
这样一堆文件怎么拿
$ ls -1 *ttl
cl.owl.txt.ttl
efo.owl.txt.ttl
htn.owl.txt.ttl
和assemble这种一般形式的命令?
$ ./robot merge \
--input cl.owl.txt.ttl \
--input efo.owl.txt.ttl \
--input htn.owl.txt.ttl \
--output merged.ttl
使用单引号或双引号似乎没有帮助:
$ jdk1.8.0_201/bin/java -Xms4G -Xmx8G -jar robot.jar merge --inputs "ontopath/*ttl"
UNKNOWN ARG ERROR unknown command or option: ontopath\efo.owl.txt.ttl
$ jdk1.8.0_201/bin/java -Xms4G -Xmx8G -jar robot.jar merge --inputs 'ontopath/*ttl'
UNKNOWN ARG ERROR unknown command or option: ontopath\efo.owl.txt.ttl
IIRC,Windows 命令解释器不进行 glob 扩展;它把它留给接收参数如 *.ttl
的命令。然而,bash
扩展了一个模式并将生成的单词作为单独的参数传递。以下是等价的:
robot merge --inputs *.ttl --output merged.ttl
robot merge --inputs cl.owl.txt.ttl efo.owl.txt.ttl htn.owl.txt.ttl --output merged.ttl
您需要引用该模式,以便它按字面意思传递给robot
以展开:
robot merge --inputs '*.ttl' --output merged.ttl
您可以自己编写一个包装器脚本,让您构建参数列表的方式有望在 Windows Java 对通配符参数的处理中幸存下来。这是一个脚本 mergefiles
:
#!/bin/bash
output=""
shift
for file
do
inputs+=( --input "$file" )
done
./robot merge "${inputs[@]}" --output "$output"
在 Git Bash 你现在应该可以 运行 ./mergefiles merged.ttl *.tll
我正在使用名为 ROBOT 的工具合并 ontology 个文件:http://robot.obolibrary.org/merge
它有一个带通配符的 --inputs
参数,但这在我的环境中似乎不起作用(Windows 10 中的 GitBash)。
这样一堆文件怎么拿
$ ls -1 *ttl
cl.owl.txt.ttl
efo.owl.txt.ttl
htn.owl.txt.ttl
和assemble这种一般形式的命令?
$ ./robot merge \
--input cl.owl.txt.ttl \
--input efo.owl.txt.ttl \
--input htn.owl.txt.ttl \
--output merged.ttl
使用单引号或双引号似乎没有帮助:
$ jdk1.8.0_201/bin/java -Xms4G -Xmx8G -jar robot.jar merge --inputs "ontopath/*ttl"
UNKNOWN ARG ERROR unknown command or option: ontopath\efo.owl.txt.ttl
$ jdk1.8.0_201/bin/java -Xms4G -Xmx8G -jar robot.jar merge --inputs 'ontopath/*ttl'
UNKNOWN ARG ERROR unknown command or option: ontopath\efo.owl.txt.ttl
IIRC,Windows 命令解释器不进行 glob 扩展;它把它留给接收参数如 *.ttl
的命令。然而,bash
扩展了一个模式并将生成的单词作为单独的参数传递。以下是等价的:
robot merge --inputs *.ttl --output merged.ttl
robot merge --inputs cl.owl.txt.ttl efo.owl.txt.ttl htn.owl.txt.ttl --output merged.ttl
您需要引用该模式,以便它按字面意思传递给robot
以展开:
robot merge --inputs '*.ttl' --output merged.ttl
您可以自己编写一个包装器脚本,让您构建参数列表的方式有望在 Windows Java 对通配符参数的处理中幸存下来。这是一个脚本 mergefiles
:
#!/bin/bash
output=""
shift
for file
do
inputs+=( --input "$file" )
done
./robot merge "${inputs[@]}" --output "$output"
在 Git Bash 你现在应该可以 运行 ./mergefiles merged.ttl *.tll