我的 Bash 脚本出现问题,当我想使用我的脚本时,它在第 8 行和第 43 行显示“模糊重定向”。我编写了脚本来处理 GPS 数据。
我的脚本如下:
#! /bin/bash
# Change 'Raw' to 'csv' for output file name
outf=${1/Raw/csv}
# Print current input- and output file name
echo \> $outf
# Remove 'Carriage Returns' and get GGA and VTG strings from file
tr -d '\r' < | egrep "GGA|VTG" | awk '
BEGIN {
# Field separator is ','
FS=","
}
# Convert deg min sec to decimal degrees
function degAngl(minAngl) {
pos = index(minAngl, ".") - 3
deg = substr(minAngl, 1, pos)
min = substr(minAngl, pos + 1) / 60
return deg + min
}
{
# if it is a VTG dump all stored data
if (substr() == "VTG") {
head=$2
velo=$8
printf ("%08.1f,%1.8f,%1.8f,%1.3f,%d,%d,%1.1f,%1.1f,%1.1f\n", time, long, lati, alti, qual, nsat, hdop, head, velo)
}
# it is not a VTG but a GGA, store data, correct for different altitude definitions
else {
time =
lati = degAngl()
long = degAngl()
qual =
nsat =
hdop =
alti = ( < 0) ? + :
}
}
' >$outf
当我运行它时,我得到:
process.sh: Line 10: : ambiguous redirect
process.sh: Line 43: 1: ambiguous redirect
关于以下几行:
line 10: tr -d '\r' < | egrep "GGA|VTG" | awk '
line 43: ' >$outf
这是什么以及如何解决这个问题?