xargs 到不同的文件中
我有一个 bash 'for 循环' 可以完成我想要的操作
for i in *.data
do
./prog $i >dir/$i.bck
done
我可以将其转换为 xargs 构造吗? 我尝试过类似的方法
ls *.data|xargs -n1 -I FILE ./prog FILE >dir/FILE.bck
,但我对“>”的 FILE 右侧有问题
谢谢
I have a bash 'for loop' that does what I want
for i in *.data
do
./prog $i >dir/$i.bck
done
Can I turn this into an xargs construct ?
I've tried something like
ls *.data|xargs -n1 -I FILE ./prog FILE >dir/FILE.bck
But I have problems with the FILE rightside of '>'
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下(如果您愿意,可以使用
FILE
而不是%
):Give this a try (you can use
FILE
instead of%
if you prefer):GNU Parallel http://www.gnu.org/software/parallel/ 就是为此而设计的任务类型:
恕我直言,这比提供的 xargs 解决方案更具可读性。
观看介绍视频以了解详情:http://www.youtube.com/watch?v=OpaiGYxkSuQ
GNU Parallel http://www.gnu.org/software/parallel/ is designed for this kind of tasks:
IMHO this is more readable than the xargs solution provided.
Watch the intro video to learn more: http://www.youtube.com/watch?v=OpaiGYxkSuQ