I would like to read a file line by line, edit the line and put it into a new file:
while read my_line
do
# doesn't handle the last OR
printf "'%s'\$label OR " $my_line >> delivered
done < "labels.txt"
Unfortunately, by following this approach, I add a OR also after the last element of my file.
I thought that in some way I could handle this case by identifying the last line: from the man page, when $? for read is different from 0, then we have the end-of-file; but in this case I can't use it inside the loop to create a different printf instruction.
Any suggestion?
Thank you