[Top][All Lists]

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

Re: process the output of $() with files with spaces

From: Eric Blake
Subject: Re: process the output of $() with files with spaces
Date: Mon, 19 Aug 2013 12:54:56 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

On 08/19/2013 11:51 AM, Enda wrote:
> Say I type:
> $ echo cat $(ls -Qv *.pdf)

Insufficient quoting.  Try:

$ echo cat "$(ls -Qv *.pdf)"

and to really see the difference, first do
 touch "two  spaces.pdf"
in the directory.  But even then, that only shows the input that you
want, but would still require an 'eval' to execute; and use of 'eval' in
shell on arbitrary file names is generally not worth the added danger.

Why are you even bothering with ls, when the following is faster and
does what you want, without having to worry about awkward quoting in the
first place?

cat *.pdf

> How do I get around this problem?

Your problem has nothing to do with coreutils, and everything to do with
shell quoting.  You may want to take this question to a forum dedicated
to proper shell usage.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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