语法错误:文件结尾意外(预期"done")



我复制了SeisUnix(SU(的shell脚本,这是一个用于地震处理的基于Linux的程序。

#! /bin/sh
#File: Nmigcvp2.sh
#       Create one panel for each migration velocity
#       Each panel has the same "fldr" value
#       The migration velocity is in key "offset"
#       Total number of panels is in key "nvs"
# Set messages on
##set -x
#================================================
# USER AREA -- SUPPLY VALUES
#------------------------------------------------
# Seismic files
indata=Nstack4.su # SU format
outdata=Nmigcvp.su # migration Constant Velocity Panels
# Migration variables
cdpmin=900      # Start CDP value
cdpmax=1300     # End CDP value
dxcdp=16.667    # distance between adjacent CDP bins (m)
smig=1.0        # stretch factor (0.6 typical if vrms increasing)
# [the "W" factor] (Default=1.0)
vscale=1.0      # scale factor to apply to velocities (Default=1.0)
lstaper=20      # length of side tapers (traces) (Default=0)
lbtaper=100     # length of bottom taper (samples) (Default=0)
# Velocity panel variables
firstv=1400     # first velocity value
lastv=2000      # last velocity value
increment=200   # velocity increment
numVtest=100    # use to limit number of velocity panels
# otherwise, use very large value (100)
#================================================
# Compute number of velocity panels
numV=`echo "( ( $lastv - $firstv ) / $increment ) + 1" |bc -l
if [ $numVtest -lt $numV ] ; then
numV=$numVtest
fi
#------------------------------------------------
# FILE DESCRIPTIONS
# tmp1 = binary temp file of input data
#------------------------------------------------
cp $indata tmp1
migV=$firstv
echo " "
#------------------------------------------------
# Loop through Migration Constant Velocity Panels
# Each panel has the same "fldr" value
# Panel migration velocity is in key "offset"
# Total number of panels (numV) is in key "nvs"
#------------------------------------------------
i=1
while [ $i -le $numV ]
do
echo " iteration number = $i Velocity = $migV"
suwind < tmp1 key=cdp min=$cdpmin max=$cdpmax |
sushw key=fldr a=$i |
sushw key=offset a=$migV |
sushw key=nvs a=$numV |
sustolt cdpmin=$cdpmin cdpmax=$cdpmax dxcdp=$dxcdp 
tmig=0 vmig=$migV smig=$smig vscale=$vscale 
lstaper=$lstaper lbtaper=$lbtaper 
>> $outdata
i=`expr $i + 1`
migV=`expr $migV + $increment`
done
#------------------------------------------------
# Remove files and exit
#------------------------------------------------
echo " "
echo " Output file = $outdata"
echo " "
rm -f tmp*
exit

当我运行脚本时,我会遇到语法错误。

./Nmigcvp2.sh: 33: Syntax error: end of file unexpected (expecting "done")
numV=`echo "( ( $lastv - $firstv ) / $increment ) + 1" |bc -l`

您在这里的行末尾缺少一个`backtick字符。如果使用彩色语法编辑器,则更容易发现这种语法错误。

在VIM中,例如使用CCD_;colorscheme elflord。您也可以对set nu行进行计数。

最新更新