The below code is not working.
I've given explanation for all the lines:
#!/bin/ksh
cat example.txt | while read LINE # reading line from file
do
var=$LINE # assigning line to variable
echo $var # printing the line
H_OR_T="${var:0:6}" # taking substring from the line
echo $H_OR_T # printing the substring
up to here the code is working fine.
If H_OR_T variable holds the hardcoded value (i.e., M$9001 kindly take a look on if condition below) I should enter the loop. But here I'm getting arithmetical errors.
if [[ $H_OR_T = "M$9001" ] || [ $H_OR_T = "M$9002" ]];
then
echo "************** MOVING HEADER OR TRAILER RECORD TO DOMESTIC FILE ************"
awk '{print $0}' example.txt > domestic.txt
else
echo "**************** MOVING RECORD TO LOGGER FILE **********************"
awk '{print $0}' example.txt > logger.txt
fi
done