Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Reini Urban
committed
Oct 5, 2011
1 parent
afd48a3
commit 3bcd452
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/perl | ||
use CPAN; | ||
CPAN::Shell->install(CPAN::Shell->r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
function filediff { | ||
BASE="`basename $FILE | sed -e 's,\(.bak\|.bk\|~\)$,,'`" | ||
NEW="`dirname $FILE`/$BASE" | ||
if [ "$FILE" = "$NEW" ]; then FILE=$(ls -t $FILE{~,.bak,.bak,.orig} 2>/dev/null | head -n1); fi | ||
if [ -e "$FILE" -a -e "$NEW" ]; then | ||
echo "$NEW" 1>&2 | ||
echo "diff -bu $FILE $NEW" | ||
/usr/bin/diff -bu $FILE $NEW | ||
fi | ||
} | ||
|
||
if [ "$#" -gt 1 -o -f "$1" ] # multiple args or a file: just these | ||
then | ||
for FILE in "$@"; do filediff; done | ||
else | ||
if [ "$#" -eq 0 ] | ||
then APATH="." # no arg: recursively all origs | ||
else APATH="$1" # or one arg: recursively all origs | ||
fi | ||
/usr/bin/find $APATH \( -name '*~' -o -name '*.ba?k' \) -print | sort | \ | ||
while read FILE | ||
do | ||
filediff | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
b= | ||
if [ "$1" = "-b" ]; then b="b"; shift; fi | ||
echo "difforig $@" | ||
echo "" | ||
#/usr/bin/date +"%Y-%m-%d %H:%M:%S <rurban@x-ray.at>" | ||
#echo "" | ||
if [ "$#" -gt 1 -o -f "$1" ] # multiple args or a file: just these | ||
then | ||
for FILE in "$@" | ||
do | ||
ORIG="$FILE.orig" | ||
echo "$FILE" 1>&2 | ||
echo "diff -u$b $ORIG $FILE" | ||
/usr/bin/diff -u$b $ORIG $FILE | ||
done | ||
else | ||
if [ "$#" -eq 0 ] | ||
then APATH="." # no arg: recursively all origs | ||
else APATH="$1" # or one arg: recursively all origs | ||
fi | ||
/usr/bin/find "$APATH" -name '*.orig' -print | /usr/bin/sort | while read FILE | ||
do | ||
NEW="`dirname $FILE`/`basename $FILE .orig`" | ||
echo "$NEW" 1>&2 | ||
echo "diff -u$b $ORIG $FILE" | ||
/usr/bin/diff -u$b $FILE $NEW | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use vars; | ||
|
||
sub usage { | ||
print "ERROR: Missing argument\n"; | ||
print "diffsize [-n][-q] dir1 dir2\n"; | ||
print " print filenames with different filesizes in both directories\n"; | ||
print " -n \tignore not existing files in 2nd directory\n"; | ||
print " -q \tprint only filenames\n"; | ||
exit; | ||
} | ||
|
||
sub size { | ||
my @s = stat(shift) or return -1; | ||
return $s[7]; | ||
} | ||
|
||
my $opt_n = 0; | ||
my $opt_q = 0; | ||
my $dir1 = shift || usage; | ||
if ($dir1 eq '-n') { | ||
$opt_n = 1; | ||
$dir1 = shift || usage; | ||
} | ||
if ($dir1 eq '-q') { | ||
$opt_q = 1; | ||
$dir1 = shift || usage; | ||
if ($dir1 eq '-n') { | ||
$opt_n = 1; | ||
$dir1 = shift || usage; | ||
} | ||
} | ||
my $dir2 = shift || usage; | ||
|
||
opendir(D1, $dir1) or die "cannot open $dir1: $!\n"; | ||
chdir $dir1; | ||
|
||
while (my $f1 = readdir(D1)) { | ||
next if -d $f1; | ||
my $f2 = "$dir2/$f1"; | ||
my $s1 = size($f1); | ||
my $s2 = size($f2); | ||
if ($s2 < 0) { | ||
if (! $opt_n) { | ||
if ($opt_q) { | ||
print $f1, "\n"; | ||
} else { | ||
print "$f1\t$s1\t$s2\t$f2 does not exist\n"; | ||
} | ||
} | ||
} elsif ($s2 != $s1) { | ||
if ($opt_q) { | ||
print $f1, "\n"; | ||
} else { | ||
print "$f1\t$s1\t$s2\t$f2\n"; | ||
} | ||
} | ||
} | ||
closedir D1; | ||
closedir D2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
# du sorted by size | ||
perl -e '%h=map{/.\s/;7x(ord$&&10)+$`,$_}`du -h @ARGV`;print@h{sort%h}' $* |