help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] How to print a string in the quote form not in the escap


From: Greg Wooledge
Subject: Re: [Help-bash] How to print a string in the quote form not in the escaped form?
Date: Tue, 26 Apr 2016 09:37:53 -0400
User-agent: Mutt/1.4.2.3i

The purpose of printf %q is not to produce pretty human-readable output.
It's there to produce reusable output, that can be fed to another instance
of bash (e.g. across an ssh session or through an eval).  It's for data
transfer and protection, not ornamentation.

http://mywiki.wooledge.org/BashFAQ/096 contains some examples of how to
use this with ssh.

printf %q is essentially the opposite of eval, so you can use
it to preemptively armor each value you *don't* want eval to
parse.  There is a bit of discussion of this use at the end of
http://mywiki.wooledge.org/BashFAQ/048 but it isn't a full-fledged
example.



reply via email to

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