Re: I need grep . help

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

 



Patrick O'Callaghan wrote:
> On Mon, 2024-09-09 at 22:32 -0400, Jon LaBadie wrote:
>> Double and single quotes seem equivalent here.  But note that inside
>> single quotes the backslash is always literal, not special, while inside
>> double quotes it depends on the character following the backslash.  If
>> it is a dollar sign ($), a back tic (`), a backslash (\), or a double
>> quote (") then the backslash quotes the following character.
> 
> Many decades of Shell usage and I still have trouble remembering the
> difference between single and double quotes.

Not specifically for you Patrick, but as a general reply to
that statement...  (I'm closer to that position than I am to
being an expert in the many, subtle differences, I'm sure.)

A very basic (and very incomplete) way to think about it is
that single quotes protect the contents from (nearly) all
shell expansions (i.e. things which change the content or
meaning of the quoted material).  Double quotes allow the
shell to expand things before passing them to the command
being run.

The rules are much more convoluted than that, of course.
Largely, that's by virtue of them being codified by what
shells have actually done rather than being designed
entirely up front before being implemented.

But asking "do I want this data to be fed as-is to the
command being run or expanded by the shell?" usually makes
the choice clear.  I tend to default to single quotes and
only change things to double quotes when necessary

By the time you have case where it's not clear, you know
that you're deep in the weeds and likely have looked up the
differences for your use-case (or figured them out through
trial and error).

-- 
Todd

Attachment: signature.asc
Description: PGP signature

-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux