The script uses the Digest::md5 module to look for duplicate files. It takes as input a list of filenames, and returns a list of all files which share the same md5 hash/signature. Files which share the same md5 signature are very likely to be duplicate files.
lovebox:~ gjl$ cp /etc/hosts file1
lovebox:~ gjl$...
Read more »
Scripts
Short single purpose scripts, in any scripting language.
Find duplicate files with Perl md5
Counting in unix with ‘uniq-c’. Or how many of something does this thing have?
Recently we were looking for common components that might indicate why some of our tests failed. One of the sysadmins at our Sunnyvale lab came up with a quick script which did the job. He used ‘uniq -c’ to great effect. In this example I look in my iTunes directory structyre...
Read more »
Returning values from shell functions, and the non-exit thereof.
So, I wanted to write a (bash) shell function that returned a value to the calling routine, rather than set a global variable. I found that the following would do what I wanted
#!/bin/bash
func() {
echo "This is the return value:"
return
}
x=$(func "param")
echo "The return value is : $x"
And this is what we see
lovebox:tmp gjl$...
Read more »
Testing variables in bash
So, one of our developers took it upon himself to re-write one of my crappy scripts, and used some odd looking shell ‘test’ invocations that I’d never seen before.
&& usage
So here we have a logical AND comparison, which calls the function...
Read more »
Commnd line options in perl
# Usage ./this_script-f /tmp/somefile.out -l 21,22,23,24
use Getopt::Std;
#Required if using strict.our($opt_f,$opt_l);
getopt(‘fl’);
my $inputfile=$opt_f;
my @list=split /,/,$opt_l;
Read more »
See what SQL is executing in Oracle ‘right now’.
select sesion.sid, sesion.username, optimizer_mode, hash_value, address, cpu_time, elapsed_time, sql_text from v$sqlarea...
Read more »
Useful Oracle scripts
space.sql Display tablespace size and current utilisation.
SQL> @/u/little/mycode/sql/dba/space
%
% MaxPoss Max
Tablespace Name KBytes Used Free Used Largest Kbytes Used
------------------- ------------- ------------ ------------ ------ ------------ ------------ ------
m SYSTEM 1,048,576 ...
Read more »
ksh script template
Here’s a nice little example of how to write and comment shell scripts.
#!/bin/ksh
#
#Display a usage message
#
usage() {
echo "usage: "
}
if ] ; then
usage
exit 1
fi
#
#Process command line options
#
while
do
case $1 in
-m) REGMODEL=$2
shift
;;
-t) REGTEST=$2
shift
;;
-p) REGPROTO=$2
shift
;;
-b) REGBLD=$2
shift
;;
-months) MONTHS_TO_Q=$2
shift
;;
-h) help=true
;;
-burt) ...
Read more »