x
Loading
 Loading
Hello, Guest | Login | Register

Accurate Quoting

To quote, or not to quote? The topic of quoting is a command-line mystery that confounds many new users. When do you use quotes, and when do you not use quotes? For instance, what’s the difference, if any, between these commands?

To quote, or not to quote? The topic of quoting is a command-line mystery that confounds many new users. When do you use quotes, and when do you not use quotes? For instance, what’s the difference, if any, between these commands?

rm * 

and

rm ‘*’ 

And then there’s the always-vexing issue of what type of quoting to use — single quoting, double quoting, or back quoting? If these are the kind of questions you’ve been asking yourself, then you’ve come to the right place. This article aims at setting straight the various Linux quoting types so that your quotes will be dead-on accurate.

To be clear, the material in this article and other articles in this series applies to the BASH shell, which is the most popular Linux shell. There are many other shells available, but covering their specific uses and functionality is beyond the scope of this article. If you use a different shell, the material will apply only to the extent that the behavior of your chosen shell conforms to that of the BASH shell. To see which shell you’re using, issue the command echo$SHELL. (It’s probably BASH.)

To Quote or Not to Quote

Quoting becomes an issue primarily because of the command-line feature known as filename globbing. Filename globbing lets you specify command arguments that refer to sets of files without having to individually list each filename. The similar, but much less sophisticated,…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. KDE 4.4: Does It Work Yet?
  2. Writing Custom Nagios Plugins with Python
  3. Power Up Linux GUI Apps
  4. Tweeting from the Command Line with Twyt
  5. When Memory Serves You: Using ramfs and tmpfs
Follow Linux Magazine
Rackspace