With ex
, that would rather be something like:
printf '%b\n' 0a 'Anything\tyou\twant\tto\tadd' . x | ex -s printf.csv
or:
printf '0a\nAnything\tyou\twant\tto\tadd\n.\nx\n' | ex -s printf.csv
Note that the escape sequences recognised by %b
arguments are not the same as that in the format argument. The former are the echo
ones, and the latter the standard C-like ones (though many printf
implementations have extension over them). That makes not difference for that \t
, but it would for \11
which you'd need to write \011
in a %b
argument (at least if you wanted to be portable).
Another option, is to use %s
but use ksh93-style $'...'
quotes for the \t
expansion:
printf '%s\n' 0a $'Anything\tyou\twant\tto\tadd' . x | ex -s printf.csv
Where they're supported (ksh93, zsh, bash, FreeBSD sh, busybox ash at least), those $'...'
quotes usually support the standard C escapes (with extensions) like in the format argument to printf
(unlike %b
arguments or echo
).