Results 1 to 1 of 1
alright so i have to get rid of the comments in a file. They start with /* and end with */. Assuming that all of these are on a line ...
- 04-23-2007 #1Just Joined!
- Join Date
- Sep 2005
- Posts
- 99
printing extra characters in bash
alright so i have to get rid of the comments in a file. They start with /* and end with */. Assuming that all of these are on a line of their own, i made a loop that goes through and detects them and avoids them. However, it prints extra characters on the first and last line. /TT_DB /UXB are printed on the first and last line where the /* and the */ would be. Everything on the lines in between prints correctly. Anyone know how it would print these extra characters at the beginning and end. My guess is because to avoid the comments i have an inner loop that continues, but it also reads the next line of the file, then i have an outer loop that also reads the next line could this be interfering with each other? Here is the loop to ignore comments and store everything else.
The part i'm concerned with is the first if statement that finds the / and then reads lines and finds the * ThanksCode:# find the points while read line do firstCoord=`echo $line | cut -d ' ' -f1` firstPoint=`echo $line | cut -d ' ' -f2` tempPoint=`echo $line | cut -d ' ' -f3` secondPoint=`echo $line | cut -d ' ' -f4` firstChar=`echo $line | cut -c1` ##echo "this is the first coord " $firstCoord #echo "this is the first point" $firstPoint #echo "this is the temp point" $tempPoint #echo "this point is hte second point "$secondPoint echo "the first char of the line is " $firstChar if [ "$firstChar" == '/' ] then while [ "$firstChar" != '*' ] do read line firstChar=`echo $line | cut -c1` continue; done fi if [[ "$firstPoint" == 'x' || "$firstPoint" == 'X' || "$firstPoint" == 'y' || "$firstPoint" == 'Y' ]] then Xpoints[$count]=$tempPoint Ypoints[$count]=$tempPoint elif [ "$firstCoord" == 'x' ] then Xpoints[$count]=$firstPoint Ypoints[$count]=$secondPoint elif [ "$firstCoord" == 'X' ] then Xpoints[$count]=$firstPoint Ypoints[$count]=$secondPoint elif [ "$firstCoord" == 'y' ] then Ypoints[$count]=$firstPoint Xpoints[$count]=$secondPoint elif [ "$firstCoord" == 'Y' ] then Ypoints[$count]=$firstPoint Xpoints[$count]=$secondPoint else Xpoints[$count]=$firstCoord Ypoints[$count]=$firstPoint fi (( count++ )) done < "xaa"


Reply With Quote