简体   繁体   中英

How to pass arguments to program in a for loop of a shell script

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, ie

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM