linux - bash printf backslash then new line -


i trying create bash c header

#define xxxxx \   "id title\n" \    "1  developer\n" \  script   format="  \"%-4s  %-32s\\\n"  printf "$format" "id" "title\\n\"" >> $file  printf "$format" "1" "developer\\n\"" >> $file 

the result

"id    title\n"                        \n  "1     developer\n"                              \n 

when change format="%-4s %-32s \\ \n"

i get

"id    title\n"                           \  "1     developer\n"                       \  

and gcc start complain space after \

it seems \\ interpreted more once if there no space.

without using format="%-4s %-32s \\"

printf "$format" "id" "title\\n\"" >> $file  printf "\n" >> $file ... 

is there better way handle this?

use hexadecimal escape sequences:

format="%-4s %-32s \x5c\n" 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -