如何在 shell 脚本的 for 循环中将参数传递给程序
我在实现一个非常简单的 shell 脚本时遇到了一些麻烦。我想运行一个使用命令行输入 2-100 作为程序参数之一的程序,并将结果定向到另一个文件,即
for (( c=2; c<101; c++))
do
./virtmem 100 $c fifo sort2 >> results/FIFOSORT.txt
done
但这不太有效,因为它说 fifo 不是程序。有什么建议吗?感谢您的帮助。
I'm having a little trouble implementing a very simple shell script. I want to run a program with command line inputs 2-100 as one of the program arguments and direct the results to another file, i.e.
for (( c=2; c<101; c++))
do
./virtmem 100 $c fifo sort2 >> results/FIFOSORT.txt
done
But this doesn't quite work because it says fifo isn't a program. Any suggestions? Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
virtmem 用这些参数做什么?如果它尝试将“fifo”作为另一个脚本运行,也许 fifo 需要“chmod +x”才能使其可执行?
What is virtmem doing with those args? If it's trying to run "fifo" as another script, perhaps fifo needs "chmod +x" to make it exec'able?
尝试执行此操作
`./virtmem 100 $c fifo sort2 >>> results/FIFOSORT.txt
`或这个
./virtmem 100 $c "fifo" "sort2" >>>结果/FIFOSORT.txt
。我认为这会解决你的问题。
Try to either do this
`./virtmem 100 $c fifo sort2 >> results/FIFOSORT.txt
`or this
./virtmem 100 $c "fifo" "sort2" >> results/FIFOSORT.txt
.I think it will solve your problem.