我有一个模拟,我正在为不同的核心分配2个进程。每个模拟在模拟结束时提取输出文件。我想做的是,在模拟结束时,应该提取结果文件如果运行编号为0,则结果文件应为result0.txt,如果为1 result1.txt(结果文件由模拟时的类创建)。我是Linux的新手,所以我不知道bash脚本。我只是想学习。我怎么能这样做呢?
#!/bin/bash
# My first script
count=0
echo -n "Enter a number of simulation > "
read number
echo "Please enter the algorithm type > "
echo -n "0 for NNA 1 for SPA 2 for EEEA > "
while read type; do
case $type in
0 ) while [ $count -lt $number ]; do
cd /home/cea/Desktop/simulation/wsnfuture
taskset -c $((count % 4)) ./wsnfuture -u Cmdenv omnetpp.ini > wsn1
count=$((count + 1))
done
;;
1 ) while [ $count -lt $number ]; do
cd /home/cea/Desktop/simulation/wsnfuture1
taskset -c $((count % 4)) ./wsnfuture -u Cmdenv omnetpp.ini > wsn1
count=$((count + 1))
done
;;
2 ) while [ $count -lt $number ]; do
cd /home/cea/Desktop/simulation/wsnfuture2
taskset -c $((count % 4)) ./wsnfuture -u Cmdenv omnetpp.ini > wsn1
count=$((count + 1))
done
;;
* ) echo "You did not enter a number"
echo "between 0 and 2."
echo "Please enter the algorithm type > "
echo "0 for NNA 1 for SPA 2 for EEEA > "
esac
done
wsn1只显示模拟的运行次数和已用时间。