get xargs quoted - Unix

This is a discussion on get xargs quoted - Unix ; How can I change this so the result passed to cat has quotes? alias catbydate='ls -rt | xargs cat *' Here's why: some files have spaces in the names and cat complains....

+ Reply to Thread
Results 1 to 5 of 5

Thread: get xargs quoted

  1. get xargs quoted


    How can I change this so the result passed to cat has quotes?

    alias catbydate='ls -rt | xargs cat *'

    Here's why: some files have spaces in the names and cat complains.

  2. Re: get xargs quoted

    In article ,
    vjp2.at@at.BioStrategist.dot.dot.com wrote:

    > How can I change this so the result passed to cat has quotes?
    >
    > alias catbydate='ls -rt | xargs cat *'
    >
    > Here's why: some files have spaces in the names and cat complains.


    You might instead trying writing a script using
    IFS=
    (i.e., empty).

    Hans Aberg

  3. Re: get xargs quoted

    2007-04-3, 18:00(+00), vjp2.at@at.BioStrategist.dot.dot.com:
    >
    > How can I change this so the result passed to cat has quotes?
    >
    > alias catbydate='ls -rt | xargs cat *'
    >
    > Here's why: some files have spaces in the names and cat complains.


    The "*" above doesn't make sense.

    For symlinks, you probably want the time of modification of the
    actual file rather than the link:

    Try:

    catbydate() {
    ls -Lrt | sed 's/./\\&/g' | xargs cat --
    }

    With zsh, you would do:

    cat ./*(-.Om)


    --
    Stéphane

  4. Re: get xargs quoted

    I was wondering if xargs -0 might work?

    the way I use this is I get a mail folder from yahoo (comes zipped)
    and I want to put it all in one text file.

    so
    catbydate >> goats2006.txt

    I'll try what was suggested.. much obliged

    - = -
    Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
    http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
    ---{Nothing herein constitutes advice. Everything fully disclaimed.}---
    [Homeland Security means private firearms not lazy obstructive guards]
    [Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]

  5. Re: get xargs quoted

    2007-04-4, 05:09(+00), vjp2.at@at.BioStrategist.dot.dot.com:
    > I was wondering if xargs -0 might work?
    >
    > the way I use this is I get a mail folder from yahoo (comes zipped)
    > and I want to put it all in one text file.
    >
    > so
    > catbydate >> goats2006.txt

    [...]

    zsh:

    {for f (*(Om)) formail < $f} > mbox

    You could do

    ls -rt | tr '\n' '\0' |
    xargs -r0 -n1 sh -c 'exec formail < "$1"' inline > mbox

    If your xargs supports -0 (which is a non-standard option).

    You probably need formail to convert the files to mbox format
    (add leading "from ..." lines).

    --
    Stéphane

+ Reply to Thread