[Nottingham] "unescaping" the wildcard character for xargs

Rory Holland rory at linux.com
Tue Jun 19 12:18:08 UTC 2012


That's what I've since discovered.

I'm rewriting in Python, frankly

On 19 June 2012 13:17, Martin <martin at ml1.co.uk> wrote:
> On 19/06/12 12:30, Rory Holland wrote:
>> Let's say I have a command which outputs line-delimited filenames with
>> wildcards in them.
>>
>> For example:
>>
>> /home/alice/*
>> /home/bob/*
>> /home/eve/*
>>
>> I'm trying to cat these files, but using the following doesn't work
>>
>> <command> | xargs cat
>>
>> This is because the * character is being interpreted literally, so I
>> get the following error on each line:
>>
>> cat: /home/alice/* : no such file or directory.
>>
>> Nothing in man xargs seems to help. What can I do?
>
>
> The "*" needs exposing to bash or whatever shell for "globbing" to be
> done by the shell for whatever your current working directory is...
>
>
> One awkward trick would be to use:
>
> <command> | while read a ; do echo $a ; done | xargs cat
>
>
> That works fine provided there are no spaces or other "interpretable"
> characters in your names.
>
>
> Hope that helps,
> Martin
>
> --
> - ------------------ - ----------------------------------------
> -    Martin Lomas    - OpenPGP (GPG/PGP) Public Key: 0xCEE1D3B7
> - martin @ ml1 co uk - Import from   hkp://subkeys.pgp.net   or
> - ------------------ - http:// ml1 .co .uk/martin_ml1_co_uk.gpg
>
> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham



More information about the Nottingham mailing list