【发布时间】:2020-01-15 02:17:49
【问题描述】:
我在一个目录中有一组文件
test1.in
test2.in
test3.in
test4.in
...
我已经编写了一个转换工具来从这些文件中提取一些数据并将其保存到另一个文件中。
我想为每个文件运行该转换工具并将结果保存到不同的输出文件中
./tool -i test1.in -i test1.out
./tool -i test2.in -o test2.out
我已经看到很多关于迭代文件并为每个文件运行所需命令的答案,但我不确定如何指定输出。
for file in dir/*.in; do
./tool -i file -o ???
done
如何为输出文件命名?
【问题讨论】:
-
在 bash 手册中阅读有关参数扩展可以做的所有漂亮事情。
-
你的例子看起来很奇怪!你的意思是你每次都想覆盖
test2.out? -
ups,这是一个错字。会改正的。谢谢指出