I am trying to create this from bash into a c header
#define XXXXX \
"id title\n" \
"1 developer\n" \
the script is
FORMAT=" \"%-4s %-32s\\\n"
printf "$FORMAT" "id" "title\\n\"" >> $FILE
printf "$FORMAT" "1" "Developer\\n\"" >> $FILE
the result would be
"id title\n" \n "1 Developer\n" \n
when I change
FORMAT="%-4s %-32s \\ \n"
I get
"id title\n" \
"1 Developer\n" \
and gcc start to complain the extra space after \
It seems that the \\ would be interpreted more than once if there is no space.
without using
FORMAT="%-4s %-32s \\"
printf "$FORMAT" "id" "title\\n\"" >> $FILE
printf "\n" >> $FILE
...
Is there any better way to handle this?
Use hexadecimal escape sequences:
FORMAT="%-4s %-32s \x5C\n"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With