coreutils
[Top][All Lists]
Advanced

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

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


From: Bob Proulx
Subject: Re: process the output of $() with files with spaces
Date: Mon, 19 Aug 2013 14:14:46 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

Bernhard Voelker wrote:
> Eric Blake wrote:
> > 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.

Or 'find' which has a -print0 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

It may be the same thing but as a matter of taste I prefer 'find'.

  find . -maxdepth 1 -name '*.pdf' -print0 | sort -zV | xargs -0 cat

Bob



reply via email to

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