[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: Bernhard Voelker
Subject: Re: process the output of $() with files with spaces
Date: Mon, 19 Aug 2013 21:30:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

On 08/19/2013 08:54 PM, Eric Blake wrote:
> On 08/19/2013 11:51 AM, Enda wrote:

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

> 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?

Probably because of the -v sorting order ... so it's - once
again - a little argument for a --null option.

Otherwise, I'd suggest something like the following to avoid
the `eval` problems:

  $ ls -1v *.pdf | xargs -d$'\n' cat

And if there are even newline characters in the file names,
then maybe this would be it:

  $ printf "%s\0" *.pdf | sort -zV | xargs -0 cat

But as already mentioned, this is not a coreutils but
rather a shell programming issue.

Have a nice day,

reply via email to

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