bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf "%q" and $'...'


From: Antonio Macchi
Subject: Re: printf "%q" and $'...'
Date: Wed, 25 Nov 2009 14:58:14 +0100
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

(Note blank line in the output -- one newline from the echo command,
and one from the actual content of $myvar.)  Using printf -v instead of
x=$(printf) means you don't suffer from the trailing-newline-removal
that command substitution does.

I'm a bit puzzled by the original e-mail, though.  I don't see what the
actual goal is.  If the goal is simply "put a newline character into a
variable", then this is even simpler:

myvar=$'\n'


my goal is very very stupid, like this

$ printf "%q" $(</bin/ls)

to get a "ascii form" of a binary file (something like uuencode)


but, as you can see, it does not work only for two binary chars

0x00, and 0x0a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]