Results 1 to 4 of 4

Thread: tar files but skip files over a certain size?

  1. #1
    Join Date
    Oct 2008
    Location
    /usr/bin/
    Beans
    493
    Distro
    Ubuntu

    tar files but skip files over a certain size?

    How can I tar files but skip files over a certain size?

    I don't want to include files over 5mb

    thanks
    Last edited by sohlinux; September 28th, 2012 at 07:12 PM.

  2. #2
    Join Date
    Oct 2006
    Location
    New York
    Beans
    1,118
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: tar files but skip files over a certain size?

    Code:
    tar -cf[z] my_archive.tar[.gz] `find dir_to_tar -type f -size -5M`
    I would suggest including the z and .gz which will gzip the archive, but since you just asked about tarring...
    I'd also run the find command first and make sure it's going to drop the files you think it will into the archive.
    I didn't see a way to do it directly from tar.
    xubuntu minimal, extensive experience, lshw: http://goo.gl/qCCtn
    blog: http://goo.gl/yLg78
    Linux viruses: http://goo.gl/6OCKA

  3. #3
    Join Date
    Oct 2008
    Location
    /usr/bin/
    Beans
    493
    Distro
    Ubuntu

    Re: tar files but skip files over a certain size?

    Quote Originally Posted by hwttdz View Post
    Code:
    tar -cf[z] my_archive.tar[.gz] `find dir_to_tar -type f -size -5M`
    I would suggest including the z and .gz which will gzip the archive, but since you just asked about tarring...
    I'd also run the find command first and make sure it's going to drop the files you think it will into the archive.
    I didn't see a way to do it directly from tar.
    thanks but it said
    tar: You may not specify more than one `-Acdtrux' option

    from / folder

    tar -cfz home-backup.tar `find /home -type f -size -5M`

  4. #4
    Join Date
    Oct 2006
    Location
    New York
    Beans
    1,118
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: tar files but skip files over a certain size?

    Try:
    Code:
    tar -cz -f home-backup.tar.gz `find /home -type f -size -5M`
    I think it's tar being picky about order and separation of options.
    xubuntu minimal, extensive experience, lshw: http://goo.gl/qCCtn
    blog: http://goo.gl/yLg78
    Linux viruses: http://goo.gl/6OCKA

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
  •