- Jan 21, 2005
- 17,722
- 6
- 81
Here is my code
But, when I run it, I am getting the following error:
In my file, line 9 is outfile=new_apedi.dat. I'd like to add that when I un-comment my echo statements, the same error shows up, but states it is at line 15 rather than line 9. Also, there are 22 lines in my test file.
Thanks for the help!
Code:
#!/usr/bin/ksh
clear
file=/home/x12960/apedi.dat
line_nbr=0
next_line_nbr=`expr ${line_nbr} + 1`
file_lines=`wc -l ${file}`
outfile=new_apedi.dat
#echo $file
#echo $line_nbr
#echo $next_line_nbr
#echo $file_lines
#echo $outfile
while [[ $line_count -lt $file_lines ]]
do
line=`sed -n "${line_nbr}p" $file`
next_line=`sed -n "${next_line_nbr}p" $file`
line_char=`echo $line | cut -c1-1`
next_line_char=`echo $next_line | cut -c1-1`
if [[ $line_char = "H" ]] ; then
if [[ $line_char -eq $next_line_char ]] ; then
echo $next_line >> $outfile
fi
else
echo $line >> $outfile
fi
if [[ $next_line_nbr -eq $file_lines ]] ; then
line_nbr=`expr $line_nbr + 1`
next_line_nbr=$next_line_nbr
else
line_nbr=`expr $line_nbr + 1`
next_line_nbr=`echo ${line_nbr}`
fi
done
Code:
./apedi.scr[9]: 22 /home/x12960/apedi.dat: bad number
Thanks for the help!
Last edited: