Wednesday, November 24, 2010

Delete files from tar archive

        You can achive this by using tar with –delete and –wildcards option

    Sample:

        for f in *.tar; do
        echo "Processing $f file..";
        tar -f $f --delete --wildcards *.log;
        tar -f $f --delete --wildcards *cache/*;
        tar -f $f --delete --wildcards *test/*;
        tar -f $f --delete --wildcards *vendor/*;
        Done

    This will create fresh tar after deleting unwanted files
  
        for f in *.tar; do
        echo "Processing $f file..";
        tar --atime-preserve -xf $f;
        chmod 777 ./nmicdst

        rm -rf ./nmicdst/cache/.*
        tar --atime-preserve -czf ./new/$f.gz nmicdst;
        rm -rf nmicdst;        done

No comments:

Post a Comment