Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
how to tar subdirectories by file type?
Results 1 to 4 of 4

Thread: how to tar subdirectories by file type?

  1. #1

    how to tar subdirectories by file type?

    Does anyone know how I can tar a directory and all its subdirectories, but only of a given file type?

    For example, I'd like to take only the .php files from:

    dir/subdir/file.php
    dir/subdir/file2.php
    dir/subdir/file.txt
    dir/file.php
    dir/file.txt

    Thus only archiving the 3 .php files.

    I tried tar -cvf dir/*.php but it didn't go into subdir.

    I know in this case I could do it manually pretty easily but I'm trying to do it with a directory that has about 20 subdirectories (some of which have subdirectories) and a large number of files in each.

    Any help?

    Thanks,
    Seth

  2. #2
    Advisor Outlaw's Avatar
    Join Date
    May 2001
    Location
    Clifton Park, NY
    Posts
    630

    Re:how to tar subdirectories by file type?

    How about:
    Code:
    [radar@Dell-i8500 tmp]$ find junk
    junk
    junk/stuff
    junk/stuff/2.php
    junk/stuff/who.txt
    junk/stuff/crap
    junk/stuff/crap/where.txt
    junk/stuff/crap/3.php
    junk/1.php
    junk/what.txt
    Code:
    [radar@Dell-i8500 tmp]$ tar cvzf - `find junk -type f -name "*.php"` >files_php.tar.gz
    junk/stuff/2.php
    junk/stuff/crap/3.php
    junk/1.php
    [radar@Dell-i8500 tmp]$ tar tzf files_php.tar.gz 
    junk/stuff/2.php
    junk/stuff/crap/3.php
    junk/1.php

  3. #3

    Re:how to tar subdirectories by file type?

    [quote author=Radar link=board=1;threadid=10827;start=0#msg97046 date=1133811504]
    How about:
    Code:
    [radar@Dell-i8500 tmp]$ find junk
    junk
    junk/stuff
    junk/stuff/2.php
    junk/stuff/who.txt
    junk/stuff/crap
    junk/stuff/crap/where.txt
    junk/stuff/crap/3.php
    junk/1.php
    junk/what.txt
    Code:
    [radar@Dell-i8500 tmp]$ tar cvzf - `find junk -type f -name "*.php"` >files_php.tar.gz
    junk/stuff/2.php
    junk/stuff/crap/3.php
    junk/1.php
    [radar@Dell-i8500 tmp]$ tar tzf files_php.tar.gz 
    junk/stuff/2.php
    junk/stuff/crap/3.php
    junk/1.php
    [/quote]

    That does it.

    Awesome, thank you.

  4. #4
    Member AljoshaNL's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    230

    Re:how to tar subdirectories by file type?

    [quote author=SethLeonard link=board=1;threadid=10827;start=0#msg97044 date=1133809828]
    Does anyone know how I can tar a directory and all its subdirectories, but only of a given file type?

    For example, I'd like to take only the .php files from:

    dir/subdir/file.php
    dir/subdir/file2.php
    dir/subdir/file.txt
    dir/file.php
    dir/file.txt

    Thus only archiving the 3 .php files.

    I tried tar -cvf dir/*.php but it didn't go into subdir.

    I know in this case I could do it manually pretty easily but I'm trying to do it with a directory that has about 20 subdirectories (some of which have subdirectories) and a large number of files in each.

    Any help?

    Thanks,
    Seth
    [/quote]
    It is easier:
    tar -cvf -recursion dir/*.php

Similar Threads

  1. Problem with mhtml file type
    By tech291083 in forum Redhat / Fedora
    Replies: 0
    Last Post: 05-11-2007, 09:17 AM
  2. Copying to subdirectories
    By countach44 in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 11-30-2004, 11:59 PM
  3. Apache error: could not open dbm (type GDBM) auth file
    By infinite_root in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 03-24-2004, 03:16 AM
  4. Flamers(no, not that type)
    By paradox in forum Announcements and Suggestions
    Replies: 1
    Last Post: 12-26-2003, 07:17 PM
  5. file type: .rar ?
    By Blaqb0x in forum Linux - General Topics
    Replies: 2
    Last Post: 09-03-2002, 11:56 AM

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
  •