Scripts

Short single purpose scripts, in any scripting language.

Find duplicate files with Perl md5

January 25, 2009
By gary

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 »

Tags:
Posted in Scripts, Uncategorized | No Comments »

Counting in unix with ‘uniq-c’. Or how many of something does this thing have?

September 20, 2008
By gary

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 »

Tags: ,
Posted in Scripts | No Comments »

Returning values from shell functions, and the non-exit thereof.

August 25, 2008
By gary

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 »

Tags:
Posted in Scripts | No Comments »

Testing variables in bash

May 22, 2008
By gary

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 »

Posted in Scripts | No Comments »

Commnd line options in perl

April 1, 2008
By gary

# 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 »

Posted in Scripts | No Comments »

See what SQL is executing in Oracle ‘right now’.

December 14, 2007
By gary

select sesion.sid, sesion.username, optimizer_mode, hash_value, address, cpu_time, elapsed_time, sql_text from v$sqlarea...
Read more »

Tags: ,
Posted in Scripts, oracle | No Comments »

Useful Oracle scripts

December 12, 2007
By gary

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 »

Tags: , ,
Posted in Scripts, oracle | No Comments »

ksh script template

October 16, 2007
By gary

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 »

Posted in Scripts | No Comments »