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: Dennis Williamson
Subject: Re: [Help-bash] How to print a string in the quote form not in the escaped form?
Date: Tue, 26 Apr 2016 08:29:22 -0500

On Apr 26, 2016 8:27 AM, "Dennis Williamson" <address@hidden>
wrote:
>
>
> On Apr 26, 2016 8:21 AM, "Peng Yu" <address@hidden> wrote:
> >
> > readability.
> >
> > On Tue, Apr 26, 2016 at 8:06 AM, Matthew Cengia <address@hidden>
wrote:
> > > No, there is not. It's escaped; why does it matter how it's escaped?
> > >
> > > On Tue, Apr 26, 2016 at 10:58 PM, Peng Yu <address@hidden> wrote:
> > >>
> > >> Hi, printf %q will print the string in the escaped form.
> > >>
> > >> ~$ printf '%q\n' "'"
> > >> \'
> > >>
> > >> I the above example, I'd like to print it as "'" (including the
double
> > >> quote). Is there a way to do so? Thanks.
> > >>
> > >> --
> > >> Regards,
> > >> Peng
> > >>
> > >
> > >
> > >
> > > --
> > > Regards,
> > > Matthew Cengia
> >
> >
> >
> > --
> > Regards,
> > Peng
> >
> The shell removes the quotes from your argument before it is passed to
printf. If you want to output quotes you will need to include them in your
format string.
>
> printf '"%q"\n' ""

Sorry I missed the single quote in the argument but the point is the same.


reply via email to

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