=========================== #!/opt/local/perl5/bin/perl # if (1 <= scalar(@ARGV)) { if (2 <= scalar(@ARGV)) { if (-d $ARGV[1]) { chdir($ARGV[1]); }else{ print "No such Directory : $ARGV[1]\n"; exit 1; } } }else{ print "\nUsage: ygrep pattern [ Directory ]\n"; exit(1); } $cwd = `pwd`; foreach (`ls -oR`) { if (/^\..*:$/) { chop; s/:$/\//; $dir = $_; }else{ @line = split; if (7 <= $#line) { $target = $dir . $line[$#line]; if (-T $target) { $res = `grep -n $ARGV[0] $target`; if (length($res) > 0) { chomp($res); $res =~ s/\n/\n$target:/g; print "$target:$res\n"; } } } } } =========================== #!/usr/perl5/bin/perl @tary = &sub_filecycle("$ENV{'HOME'}/exec/tool/backup"); foreach $zfile (@tary){ if ($zfile =~ /\.tar\.Z/){ print $zfile . "\n"; open(IN,"zcat $zfile | tar tvf - |"); while(){ print; } close(IN); print "\n"; } } exit 0; #----------- file only cycle ---------------- sub sub_filecycle { local(@a); local($b); local($t); local(@rtn); my(@a) = @_; open(IN,"ls -aR $a[0] |"); while(){ chomp; if (/^.*:$/){ s/:$//; s/^\.//; s/\/$//; $b = $_; }else{ if (!/^\.$/ && !/^\.\.$/ && $_ ne ""){ $t = $b."/".$_; if (-f $t){ push(@rtn,$t); } } } } close(IN); (@rtn); } ===========================