Shell Script Repository

Feel free to download and use any of the scripts found here for your own use. They are distributed under the terms of the GNU General Public License. These scripts have been written over a large period of time. Some are complex, some are simple. Some are elegant, some are quick hacks. Some are for Linux, others Solaris, etc. I suppose what I'm trying to say is your mileage may vary! This is just a snapshot of what's in my $HOME/bin directory at the moment!

As well as the repository, check the Tips and Tricks archive for more code snippets, scripts and useful information.

For your convenience (I think....) all scripts will open in a new browser window when you view them. This should make comparing and contrasting scripts a bit easier.

If you would like a complete archive of all the following scripts, please download the tarball.

You may find my .kshrc file useful too.

1grep D/L grep for first match of searchstring, then exit
2shells D/L Open a bash xterm and a ksh xterm
8ball D/L Magic eight ball!
ab D/L Address book implemented in shell scripts
add_entry D/L Add an entry to my address book
anu D/L Add a new user to the system
binlist D/L Show contents of $HOME/bin and count files
bintar D/L Backup $HOME/bin and optionally send to remote host
blankcat.awk D/L concatenate multiple blank lines
blankcat.sed D/L concatenate multiple blank lines into a single blank line
bzip_old_logs.sh D/L bzip logs older than $1 days
c D/L Clear screen. Should just be an alias!
calc D/L Simple front end to bc
cecho D/L An "echo" beautifier - supports colours and boldface
centre_string D/L Centre a string in a terminal window, using symbols if required
check_access_log.sh D/L Apache access_log parser to generate report detailing Google searchterms and referrers
check_arkeia.sh D/L Script to parse and analyse arkeia logs
check_bigip_time.sh D/L Nagios plugin - check time deviation between two F5 BIG-IP LTM nodes
check_conf.sh D/L Wrapper around named-checkconf to check named.conf files and mail on error
check_db_cap.sh D/L Check Sybase DB Capacity
check_iostat.sh D/L Script to monitor iostat counters for a specific disk
check_jboss.sh D/L Nagios plugin to montior JBoss thread count and JVM Free Memory
check_linked_x11.sh D/L Script to check if apps are linked against libX11
check_logs.sh D/L Script to parse JBoss log files
checkLostFound D/L Quick check of lost+found directories - should be scheduled as a cronjob
check_lsof.sh D/L Parse information generated with lsof_process.sh
check_mailq.sh D/L Nagios plugin to monitor Postfix mail queue
check_mem.sh D/L Nagios Plugin - Check Solaris memory utilisation
check_named.sh D/L Simple script to check if named is running, and alert if its not
check_pool.sh D/L Nagios plugin wrapper around poolstats.sh to check http-based pools
check_pset.sh D/L Nagios Plugin - Check load/usage of a Solaris processor pool
checkrbl.sh D/L Check multiple RBLs on robtex.com to see if an IP is listed
check_serials.sh D/L Perform DNS zone serial check against two reference nameservers
check_spamhaus.sh D/L Script to check Spamhaus RBL's to see if IP is listed
check_svcs.sh D/L Nagios Plugin - Check status of a Solaris SMF controlled service
check_temps.sh D/L Wrapper around prtpicl to check temperature sensors on compatible Sun boxen
check_tomcat.sh D/L Check BIG-IP tomcat pool for member status - requires pool.sh
check_zone_mailq.sh D/L Nagios Plugin - Check mailq size of a local Solaris zone
check_zone.sh D/L Nagios plugin - Check status of a Solaris zone
chkhard.sh D/L Script to check Red Hat Enterprise Linux AS 4 OS-level security for security risks
clp D/L Simple script to show a clear output of $PATH
common_functions.sh D/L Library of common shell script functions
compress-syslogs.sh D/L Compress old syslogs (or compress anything really...)
config_backup.sh D/L Backup configuration files from multiple servers using scp
configure_pset_pool.sh D/L Configure Processor Pool for zone implementation (Solaris 10)
console.pl D/L Interactive shell demonstration script
convert_basic_form_auth.sh D/L Script to generate HTML for JMX and Web console login pages (JBoss), and convert from BASIC auth to FORM auth
cpcpio D/L Duplicate a directory tree using cpio pass through
cpiobak D/L Selective system backup script
create_config_tar.sh D/L Create a tar file of specified input files - for backing up configuration files
daily_backup_report.sh D/L Detailed NetBackup report designed to be scheduled daily via cron
dec2hex D/L Convert a decimal number to hex (or vice versa - hard link)
delete_entry D/L Delete an entry from the address book
deploy_zazzybob_external.sh D/L Script to deploy zazzybob.com to External Environment
digg.sh D/L Hourly HTML mailout of Digg.com RSS feed
dilbert.sh D/L Fetch latest Dilbert strip and email it to me
dirfind D/L Search through specified subdirectories without descent
diskstat D/L Display disk statistics
dump_tables.sh D/L BCP data out of specifed Sybase tables
empty_dirs.sh D/L Script to check for empty subdirectories within a specified directory
encdec.sh D/L Simple wrapper to openssl for encryption and decryption
expire_frozen_media.sh D/L Check for Netbackup frozen media and expire them
figfont D/L List installed figlet fonts
fix_html.sh D/L Script to format shell code redirection and ampersand into HTML entities
fix_makefile.sh D/L Fix perl Makefiles for modules that fail to compile under Solaris
force_mailq_purge.sh D/L Script to forcibly remove messages from sendmail mail queue
ftf D/L ftp a single file
ftplog D/L Check ftp logfile for failures, etc
generate_calamaris.sh D/L Cron-able script to generate Calamaris 3 Squid proxy reports
get_cert_info.sh D/L Get SSL certificate info for HTTPS virtual servers (BigIP)
getip D/L Get IP from /etc/hosts
getips.sh D/L Get IP addresses of network interfaces under Linux
get-jboss-logs.sh D/L Script to perform daily backup of JBoss logfiles. Checks using md5sum for successful transmission
get_nic_vendor.sh D/L Look at NICs (Linux), grab MAC addresses and perform a Vendor lookup
getopts D/L getopts template script
get_patch_date.sh D/L Show dates that Solaris patches were installed
get_rpm_info.sh D/L Grab specific information from RPM headers, and display in order specified
gi D/L Wrapper for case-insensitive grep
grep.py D/L PYTHON - simple grep through a file - supports regex
hex2dec D/L Convert a decimal number to hex (or vice versa - hard link)
hgrep D/L Highlighted grep
hical D/L Simple highlighted calendar script - highlights the current day
home_space D/L Display home directory usage statistics for all users
htpasswdctl D/L Frontend to the htpasswd command
install_slave_config.sh D/L Installs the newly transferred slave named.conf file after consistency checks
iplist.sed D/L get ip addresses from file
jbossctl.sh D/L Advanced JBoss control script
jboss_passwd.sh D/L Script to change admin password for JBoss JMX and WEB consoles
jvm_free_mem.sh D/L Get JVM Free Memory for a JBoss instance
kf D/L quick find wrapper for searching current directory
kmkdir D/L Wrapper for mkdir that allows -m (mode) and -o (owner:group)
lag D/L Grepped ls -la
last10 D/L Display last 10 logins for a given user
lastSevenDays.pl D/L Output the last seven days, in a format that can be passed to grep -f for sccli_mon.sh
lgrep D/L Display lines before and/or after a match in a file
linelength D/L print each line in file prefixed by it's line length
linum.awk D/L Quick line numbering awk script
linum.pl D/L Quick and simple line numbering perl script
listips D/L list ip addresses - requires iplist.sed
lld D/L ls of directories
llg D/L Grepped ls -l
llm D/L Paged ls -l
llt D/L Paged ls -lt
login_limiter.sh D/L Limit user logins to a specified number of sessions
logmaint D/L log maintenance script
logrevolver.sh D/L Log rotation script, able to rotate and compress logs - run from cron
lol2sh.sh D/L Basic LOLCODE to BASH converter - see http://lolcode.com ;-)
lscpio D/L List partial or full contents of a cpio.gz archive
lsof_process.sh D/L Collect lsof information at intervals for a PID
mail_iostat.sh D/L wrapper around check_iostat.sh to mail results if disk status has changed
mailmon.pl D/L mailmon.pl - Gather Postfix statistics from the current /var/log/maillog file
mail_summary.pl D/L Script to parse /var/log/maillog or equivalent and provide brief summary of outbound mail
maxline.awk D/L Awk: Print out longest line, together with number of chars
memprint D/L Display memory usage report
minmaxave D/L Show minimum, maximum, sum and average for a list of integers
mkbinarchive D/L Create tarball of all scripts
mkbinhtml D/L Make bin.html file
mkbintars D/L Prepare scripts for upload to server
mkcpio D/L Create a gzip'd cpio archive
mk_large_file.ksh D/L
mkps D/L Quick script to create a PDF file from .tex source
mksh D/L Create script from template
moz D/L Open page in mozilla
mp D/L Format man output for printing
multitop.sh D/L SSH into multiple servers, and display top process from each one, continually updating "in-place"
myterm D/L myterm - Display information about the current terminal
neartime D/L Display the time in a "relaxed" format
net D/L Emulate windows "net send" command
news_archive.pl D/L Perl: Update news links
nfsmnt D/L Mount remote file storage via NFS
nicspeed.sh D/L Gather nic speed and negotiation capabilities under Solaris
nman D/L Use my personal manpage store
notes_cat.sh D/L Script to display an item from my personal MySQL notes database
notes_loader.sh D/L Script to load my notes files into my personal MySQL notes database
notes_search.sh D/L Script to search my personal MySQL notes database
nrped D/L init.d script for nagios NRPE daemon
numon D/L count of logged on users
pgk D/L Grepped ps
pgrp D/L Simple script to display users primary group membership
pinglan D/L Configurable script to ping my LAN
pingscan.pl D/L Ping a /24 network and report on host status
pingscan.sh D/L Script to pingscan a subnet and report on host status
poolgrep.sh D/L Grep through BIGIP pools for specific members
pool.sh D/L Enable, disable and check BIG-IP pool members
poolstats.sh D/L Display active/inactive status for members of a BIGIP pool, optionally checking HTTP
port_usage.sh D/L use this where lsof (for lsof -i tcp:) isn't available
pre_format.sed D/L sed to replace any < or > symbols between pre tags
provision_zone.sh D/L Fully featured script to provision a Solaris 10 zone
psplit.pl D/L Perl: Split a file into chunks and prepend each chunk with a header
purge_mailq.sh D/L Remove double-bounces from sendmails mailq
quser D/L Script to query /etc/passwd and give user information
r13 D/L Simple rot13 filter
rand D/L Generate a random number between zero and an upper bound inclusive
random_man.sh D/L Select a random man page
ratetool.pl D/L Apply ratings to objects, and manipulate ratings
remcoms.sed D/L Remove C/C++ comments from files
remove_useless_files.sh D/L Script to remove old quarantine and virus mails, plus cocoon logs from web/mail servers
rems D/L print out my reminders
revwords D/L Reverse order of words on each line of a file
revwords.awk D/L AWK - Reverse order of words in each line of a file
rmblanks.sed D/L quick 'n' dirty sed script to remove blank lines
rmempty D/L Script to remove empty files in a given directory
rndc_reloader.sh D/L Reload multiple zones for a specific view
rndm D/L give a random number
rping D/L Pings IP addresses listed in file
rsyncd D/L init.d script for rsyncd
ruler D/L print a ruler of the specified width across the screen --
sccli_mon.sh D/L sccli show events mailer for past seven days (StorEdge 35xx)
search_entry D/L Search address book for an entry
select_from_table.sh D/L Script to demonstrate how to dynamically generate SQL, then pull data from Sybase
serial_check.sh D/L Check zone serials across multiple nameservers
showcol D/L Filter to output specified columns
skel.sh D/L Template for writing your own nagios plugins
slu D/L Update site last updated date on index.html
sm D/L Mount a samba share
smu D/L Unmount a samba share
solaris_system_info.ksh D/L Highly detailed Solaris system information gathering script
spooky.sh D/L Display a "spooky" typed message on the console
sqlkb D/L connect to pgsql knowledge base
sshall.sh D/L SSH into multiple servers and execute the same command on each
striptags2.sed D/L strip HTML tags from input and remove blank lines
striptags.sed D/L strip HTML tags from input
sugid D/L Find SUID and SGID files over the entire filesystem
swapapp.sh D/L Swap application versions by maintaining a symlink
swap_stats.sh D/L Script to display top 20 process swap utilisation in KB
sybdump.sh D/L Sybase Backup Script
sync_to_slave.sh D/L Script to parse a basic named.conf file, and convert from master to slave configuration
syncusb D/L Script to backup zazzybob.com website to USB databar
sysinfo D/L System Information Script
t50 D/L Tail 50 lines of log and pipe through more
tcltree.tcl D/L TCL - produce directory listing in tree format recursively
termtest D/L A nice script demonstrating terminal control - like "minesweeper"
testbk D/L HP-UX test backup
testit D/L Simple template for creating a getopts style script
test_ns.sh D/L Query multiple nameservers for specific records
tftpdctl D/L Simple script to control the Trivial File Transfer Protocol Daemon (tftpd)
thread_count_ps.sh D/L Get JBoss thread count as a count of LWPs
thread_count.sh D/L Get active thread count for a JBoss instance
time_webserver.sh D/L Excercise a webserver by repetitively calling a URL
tipadm D/L Script to generate zazzybob.com tip index files
tips D/L Fully featured tips database - in bash
tomcat_response.sh D/L Check tomcat response times and generate a report
uncpio D/L Fully or partially restore gzip'd cpio archive made with mkcpio
update_bin D/L wrapper to update various things on bin.html
upweb D/L upload website to hosting provider
usbdisk.sh D/L Script to remount /dev/sda1 and change ownership
vali_date D/L Thorough date validation script - checks leap years too
valip D/L Simple script to validate IPv4 addresses - use as a filter
version D/L Print versions of multiple programs passed as arguments
vh D/L edit hosts as root
vinamed D/L Wrapper for "vi /etc/named.conf" with lock file editing protection
vish D/L create an empty executable file
warnme D/L warn me after a given time
watchlog D/L start xterm for log-watching
watch.sh D/L Script to monitor command execution where "watch" unavailable
webserver_conf.sh D/L Script to scp httpd configuration from webservers
whoc D/L Display count of each users sessions
whog D/L quick and dirty grep through whoc output
whot D/L Display top 10 users by session count
winword D/L launch word under wine
wireshark.sh D/L Start script for wireshark under MAC OS X 10.4
wotd.sh D/L Script to grab word of the day from dictionary.com
wun D/L Display all logged on users, their real names, and session count
wwwadmin.pl D/L Perform automated FTP transfer, creating directories as required
xtitle D/L Set title of an xterm window
xtt D/L start an xterm with the given title
zall D/L Send a command to all child zones
zbos D/L Simple launcher for ZbOS

Created with mkbinhtml on 29-11-07

Valid CSS!

Valid HTML 4.01!