Hi
I use the below commands in a script to extract the header line from a file, remove the first couple of zeros and then write the value to another file.
hdrLine=`head -1 $REF_FILE`
echo $hdrLine | sed s/"00"//g | read COMP_LINE
echo $COMP_LINE >> $COMPLETE_FILE
The problem I have is that in the header record there are a number of fields of 8 characters that are left justified and padded with spaces (where the value is less the 8 chars). I need to preserve this fixed length but the above drops a lot of the whitespace.
I partly corrected this by quoting the variables in the echo command but the final field in the record still had a probelm and was being truncated. Eventually I used the following...
hdrLine=`head -1 $REF_FILE`
echo "'$hdrLine'" | sed s/"00"//g | read COMP_LINE
echo "$COMP_LINE" | sed s/"'"// >> $COMPLETE_FILE
This works but I am wondering if there is a better and less clunky way?
cheers
Mike
I use the below commands in a script to extract the header line from a file, remove the first couple of zeros and then write the value to another file.
hdrLine=`head -1 $REF_FILE`
echo $hdrLine | sed s/"00"//g | read COMP_LINE
echo $COMP_LINE >> $COMPLETE_FILE
The problem I have is that in the header record there are a number of fields of 8 characters that are left justified and padded with spaces (where the value is less the 8 chars). I need to preserve this fixed length but the above drops a lot of the whitespace.
I partly corrected this by quoting the variables in the echo command but the final field in the record still had a probelm and was being truncated. Eventually I used the following...
hdrLine=`head -1 $REF_FILE`
echo "'$hdrLine'" | sed s/"00"//g | read COMP_LINE
echo "$COMP_LINE" | sed s/"'"// >> $COMPLETE_FILE
This works but I am wondering if there is a better and less clunky way?
cheers
Mike