On Sat, Apr 18, 2020 at 05:37:52AM +0700, Robert Elz wrote: > The end result is as Greg said, "Don't do that", if precisions are > needed with %q do something like > > printf 'echo %q%q\n' "$(printf %.2s "a'b")" ';ls'
Or something like printf '%q\n' "${myvar:0:2}" since I would assume the content to be truncated-and-quoted is in a variable.