Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: [SOLVED] RAR created 110,548 files in my ~./ !!!!!!

  1. #11
    Join Date
    Aug 2007
    Beans
    58

    Re: RAR created 110,548 files in my ~./ !!!!!!

    Code:
    $ seq 1 110548 | sed 's/^/ncaaplaybook.part./' | xargs touch
    $ time bash -c 'find ~ -name "ncaaplaybook.part.*" | xargs -n 100 rm'
    
    real	1m18.067s
    user	0m0.772s
    sys	0m5.012s
    Code:
    $ seq 1 110548 | sed 's/^/ncaaplaybook.part./' | xargs touch
    $ time bash -c 'find ~ -name "ncaaplaybook.part.*" | xargs rm'
    
    real	1m14.515s
    user	0m0.376s
    sys	0m3.620s
    Code:
    $ seq 1 110548 | sed 's/^/ncaaplaybook.part./' | xargs touch
    $ time bash -c 'ls ncaaplaybook.part.* | xargs rm'
    bash: /bin/ls: Argument list too long
    rm: missing operand
    Try `rm --help' for more information.
    
    real	0m7.987s
    user	0m3.664s
    sys	0m0.284s
    So it seems globbing doesn't work for this many arguments.

  2. #12
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: RAR created 110,548 files in my ~./ !!!!!!

    A couple notes: First, you should never parse the output of ls. It's human-readable, but it's not designed to be machine-parseable, and it can sometimes do the wrong thing.

    Try this:
    Code:
    for i in ncaaplaybook.part*; do
      rm -f "$i"
    done
    You can't list that many files on the command line, but you can loop over them. This script considers them all one at a time, so it might not be the fastest, but it's guaranteed to work.

  3. #13
    Join Date
    Aug 2007
    Beans
    58

    Re: RAR created 110,548 files in my ~./ !!!!!!

    A couple notes: First, you should never parse the output of ls. It's human-readable, but it's not designed to be machine-parseable, and it can sometimes do the wrong thing.
    Agreed, the safest thing to do, if possible, is something like:

    Code:
    find path expression -print0 | xargs -0 command

  4. #14
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: RAR created 110,548 files in my ~./ !!!!!!

    Quote Originally Posted by panayk View Post
    Agreed, the safest thing to do, if possible, is something like:

    Code:
    find path expression -print0 | xargs -0 command
    Yes, but I should point out that shell globbing (such as in the for loop I gave) is equally safe. However, a properly-crafted find command is more efficient. I'm just too lazy to learn the ins and outs of find.

  5. #15
    Join Date
    Jun 2008
    Location
    SATA1 block 3054 sector 4
    Beans
    466
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: RAR created 110,548 files in my ~./ !!!!!!

    Quote Originally Posted by mssever View Post
    Yes, but I should point out that shell globbing (such as in the for loop I gave) is equally safe. However, a properly-crafted find command is more efficient. I'm just too lazy to learn the ins and outs of find.
    Thanks guys i fixed it! i used the find command and used xargs+rm to delete the results. rm was giving an error becuase i had already deleted the files! please respond to my other post. thanks you guys for your help

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •