错误是:
line 20: $1: ambiguous redirect
可能是什么问题呢
#! /bin/bash
while read line
do
string=$line
array=(${string//,/ })
fileName=${array[0]}_"final_fitness.out"
echo $line > vt.txt
./a.out vt.txt
while read line1
do
if `echo ${line1} | grep "#" 1>/dev/null 2>&1`
then
echo "";
else
echo ${array[0]},$line1 >> full_log
break;
fi
done < $fileName
done < $1
答案1
您可以启动不带参数($1)的脚本,例如:
./myscript
用这个:
./myscript my_parameter
您的脚本中存在许多问题:
1 #! /bin/bash
2
3 while read line
4 do
5 string=$line
6 array=(${string//,/ })
7 fileName=${array[0]}_"final_fitness.out"
8 echo $line > vt.txt
^––SC2086 Double quote to prevent globbing and word splitting.
9 ./a.out vt.txt
10 while read line1
11 do
12 if `echo ${line1} | grep "#" 1>/dev/null 2>&1`
^––SC2092 Remove backticks to avoid executing output.
^––SC2006 Use $(..) instead of legacy `..`.
^––SC2086 Double quote to prevent globbing and word splitting.
13 then
14 echo "";
15 else
16 echo ${array[0]},$line1 >> full_log
^––SC2086 Double quote to prevent globbing and word splitting.
^––SC2086 Double quote to prevent globbing and word splitting.
17 break;
18 fi
19 done < $fileName
^––SC2086 Double quote to prevent globbing and word splitting.
20 done < $1
^––SC2086 Double quote to prevent globbing and word splitting.