| Paul L. Snyder on 26 Jan 2013 14:36:30 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [PLUG] Update: Strange Bash Behavior vis-a-vis Embedded Spaces and Wildcards |
When in doubt, turn to the manpage. The rule for double-quoted strings
is simple:
Enclosing characters in double quotes preserves the literal value of all
characters within the quotes, with the exception of $, `, \, and, when
history expansion is enabled, !.
Single-quoted strings are even simpler:
Enclosing characters in single quotes preserves the literal value of
each character within the quotes. A single quote may not occur between
single quotes, even when preceded by a backslash.
If you want globbing, it has to be done outside of a quoted context.
Paul
On Sat, 26 Jan 2013, Doug Stewart wrote:
> In bash, " quoted strings should have all variables and wildcards expanded
> while ' quoted strings should parse as liberals, so I'm not sure if that's
> correct...
>
> On Saturday, January 26, 2013, David Coulson wrote:
>
> > Your quote includes the asterisk, so it is interpreted as a literal,
> > rather than wildcard.
> >
> > Sent from my iPad
> >
> > On Jan 26, 2013, at 5:27 PM, Casey Bralla <MailList@nerdworld.org<javascript:;>>
> > wrote:
> >
> > > Ooops, I over-simplified the example:
> > >
> > > try
> > >
> > > ls "directory with spaces/*name" (with a wildcard).
> > >
> > >
> > >
> > > but
> > >
> > > ls directory\ with\ spaces/*name works
> > >
> > >
> > >
> > > Also, as David Coulson suggested
> > >
> > > ls "directory with spaces"/*name also works.
> > >
> > > It must be something with the quoted wildcard.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Saturday, January 26, 2013 4:13:37 PM Casey Bralla wrote:
> > >> I recently tried to do a file deletion and got some strange results.
> > >>
> > >> If I did this command:
> > >>
> > >> rm "/directory with spaces/filename" (with quotes around the full path
> > and
> > >> file name) the command would error out with a file-not-found error.
> > >>
> > >> However, this command works just fine:
> > >>
> > >> rm /directory\ with\ spaces/filename
> > >>
> > >>
> > >> I thought quoting the filename would work, but I had to escape the
> > spaces
> > >> to make it work. I find the escape method to be difficult to read,
> > while
> > >> the quoted string is very easy. Hence, I always use the quoted method.
> > >>
> > >> Can anybody explain why the quoted string does not work?
> > >
> > > --
> > >
> > >
> > > Casey Bralla
> > >
> > > Chief Nerd in Residence
> > > The NerdWorld Organisation
> > > www.NerdWorld.org
> > >
> > ___________________________________________________________________________
> > > Philadelphia Linux Users Group --
> > http://www.phillylinux.org
> > > Announcements -
> > http://lists.phillylinux.org/mailman/listinfo/plug-announce
> > > General Discussion --
> > http://lists.phillylinux.org/mailman/listinfo/plug
> > ___________________________________________________________________________
> > Philadelphia Linux Users Group --
> > http://www.phillylinux.org
> > Announcements -
> > http://lists.phillylinux.org/mailman/listinfo/plug-announce
> > General Discussion --
> > http://lists.phillylinux.org/mailman/listinfo/plug
> >
>
>
> --
> -Doug
> ___________________________________________________________________________
> Philadelphia Linux Users Group -- http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug