[Gllug] shell quoting problem
Joachim Gleissner
joe at ugh.de
Wed Jul 2 10:43:05 UTC 2008
Hi,
On Wed, Jul 02, 2008 at 10:47:13AM +0100, Alain Williams wrote:
> A little problem that is rearing its head more and more since some of my clients
> insist on creating files with spaces in the names. An example that happened just
> now:
>
> I wanted to find files that had 'John Smith' as part of the name and 'ls' them.
>
> ls -l $(locate 'John Smith')
> Doesn't work since the spaces are interpretted as argument separators - as I expected.
>
> ls -l "$(locate 'John Smith')"
> Doesn't work since ls looks for a big long file name with embedded \n in it.
>
> The simplest that I can achieve is:
>
> (IFS=: ; ls -ld $(locate 'John Smith' | tr '\n' : ))
That will probably break for filenames with a : in it. How about this:
locate 'John Smith' | xargs -d'\n' ls -l
Joe
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list