These scripts are tools I have created to solve simple problems. I hope you find them useful. The documentation below is just enough to get you started. The scripts themselves should be easy to understand; feel free to customize for your situation.

Of course these come with no warranty or any license whatsoever.

Installation

To install these files, copy them to a directory in your path. Create the symlinks as outlined below.

Usage

cdin/cdout

With mandrake 8.2, my system does not automount CD's. This works pretty well, but having to manually mount CD's is awkward. Also, having to reach down and press the drive's button is a pain too. This script handles opening and closing of the drive door and mounts and unmounts the CD as necessary.


To insert a CD, type

[user@mach dir]$ cdin

The drive door opens, and this message appears:

Insert CD and press [enter]

Place the CD in the tray and press enter. The door closes and the CD is mounted.


To remove the CD, type

[user@mach dir]$ cdout

The CD is unmounted, and the drive door opens. This message appears:

Remove CD and press [enter]

Remove the CD from the tray and press enter. The door closes.


These two scripts are really one script (cdout). You must create a symlink to create the cdin command:

[user@mach dir]$ ln -s cdout cdin

fnd/fndll

This is a simple script for finding files. It uses the standard find command to find files in the current directory and its subdirs. Running the script without any options gives:

Usage: fnd [-t text-to-find] [-f] filename-regex
-f Follow symbolic links

Note that both text-to-find and filename-regex are regular expressions. All searches are case-insensitive. Examples:

[user@mach dir]$ fnd '\.txt$'

will find all files ending in ".txt". Note that the syntax for regular expressions is different from the syntax used for specifying files. Be sure to enclose regular expressions in quotes to prevent expansion by the shell.

[user@mach dir]$ fnd -t 'alias' '^\.'

will find all files beginning with a '.' (hidden files) that contain the word alias.

The fndll script is really just a symlink to the fnd script. fndll prints the output of ls -l for each file found, rather than just the name. fndll must be created with a symlink:

[user@mach dir]$ ln -s fnd fndll

hog/hogd

The hog script lists the subdirectories below the current directory that consume the most drive space. The largest directories are listed, and only the contents of each directory (without subdirectories) is considered. Sizes are listed in "human" form using MB or GB suffixes.

The hogd script lists the subdirectories that contain consume the most space. Subdirectories of a directory are included in the drive space calculation.

lookup

There is a wealth of documentation already installed on your GNU/Linux system. Finding that documentation is sometimes tricky and always time consuming. The lookup script speeds up this process:

Usage: lookup [-v exclude] [-k] string
where string is file to search for and exclude is string to exclude.
Use -k option to use konqueror browser, default is links.

Any file whose name matches the regular expression string and is one of (html, htm, pdf, text) will be added as links to a temporary html file, and that file will be displayed in the text-mode links browser. You can use a GUI browser, but that can take too long to load for the impatient. Change the line

browser=konqueror

at the start of the script file to use the graphical browswer of your choice. Use the -k option to select the graphical browser instead of links.

pkg

The pkg command takes a command name as input and prints the name of the RPM package that the command belongs to. Basically it replaces this often-used command:

[user@mach dir]$ rpm -qf `which command`

An option (-i) causes rpm to be called with the -i option, which gives more information about the package.

system-log

Every GNU/Linux system should have a log of changes made to the system:

When trouble stikes, this log information is valuable. I never bothered recording changes until I thought of using this script.

The system-log script allows you to easily add time-stamped comments to a single system log file. To change the name of the logfile used, change this line at the top of the script to use the file you want:

logfile=$HOME/linux_info/system.log

When you start system-log, the program prompts for input:

[user@mach dir]$ system-log
Enter changes, terminated with single '.' or end of file:
>>_

Just do what the prompt says - enter a message that describes your changes. When you are done, enter a line which contains only a single line, or press control-D. The logfile will be appended with a time-stamped comment.