#!/usr/bin/perl -w # zstrip by zentara@highstream.net # ©2/22/2002 copyright #-usage: zstrip topdir test(optional) ; zstrip will recursively do a d +irectory, defaults to '.' #-runs 'strip' on all system binary executables and .so files #-excludes .a and .o files and misc non-executable binaries such as gr +aphics #-skips /proc, /boot and /home, will hang if run on /proc #-remove the /home in the match test to use in /home #-makes shared libraries faster to load, and use less memory #-recovers harddrive space from unstripped files, space recovered is r +eported #-log all output to file zstrip.log # This code is distributed under the GNU General Public License (GPL). + See # http://www.opensource.org/gpl-license.html and http://www.opensource +.org/. # USE AT YOUR OWN RISK, ALWAYS MAKE BACKUPS FIRST use strict; use File::Find; use Cwd; my $tot = 0; my ($topdir,$testmode) = @ARGV; if ($topdir eq '.'){$topdir = cwd()} if ((!defined $topdir) or !(-d $topdir)) { print 'You have not entered a directory. Usage: zstrip topdir test (optional, will only print found f +iles) Default-> will run in testmode in current directory. Continue? (n)/y '; if (<STDIN>=~ /^[yY]/) {$topdir = cwd(); $testmode = 1; &strip}} if (defined $testmode){ print "Running test on $topdir, continue? (n)/y "; if (<STDIN> =~ /^[yY]/){&strip} else {exit}} else {print "Running real strip on $topdir, continue? (n)/y "; if (<STDIN> =~ /^[yY]/){&strip} else {exit}} exit; sub strip{ open (STRIPLOG,"+>zstrip.log"); select STRIPLOG; open STDERR, ">&STRIPLOG" or die "Can't capture STDERR"; find (\&found, $topdir); print 'Total space recovered is ',$tot,"\n"; close STRIPLOG; select STDOUT; print 'Total space recovered is ',$tot,"\n"; close STDERR; exit; } sub found { my $file = $File::Find::name; if ($file =~ m#^(/proc|/boot|/home)#) {return} return unless -f; return if -l; if ($file =~ m/(\.o|\.a|\.la|\.bmp|\.xpm|\.gif|\.png|\.jpg|\.jpeg|\ +.ico|.\avi|\.mpg|\.mp3|\.wav|\.gz|\.tgz|\.z|\.Z|\.bz2|\.tar)$/) {retu +rn} if ((/\.so/) or (-B and -x)){ my $s = -s $file; print "$file\t$s\t "; unless(defined $testmode){system "strip $File::Find::name"} my $s1 = -s $file; print $s - $s1,' stripped',"\n"; $tot += ($s - $s1); }}

In reply to zstrip by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.