Script Archive
It is sometimes necessary to remove comments (preceded by #),
since this is not legal syntax.
- Desktop calculator
- This script from sed guru Greg Ubben
is a full implementation of the UNIX desktop calculator dc.
dc is an arbitrary precision, multi-base, stacking calculator.
Read how it's done in Greg's
analysis.
- Display a calendar (i)
- Display a simple calendar for the current month,
à la the UNIX command cal.
Note that bc and date are required.
- Display a calendar (ii)
- Hairier version of the above. Attempts to make sed do more of the work.
- Horizontal banner
- Rotates the vertical output of banner to produce horizontal output.
The script assumes a screen size of 80x60. This could be overcome.
- Indexer
- This script collates a list of references to produce an index
suitable for a book or magazine. A detailed description of the way it
works, along with alternative versions of the script, is available on
the tutorials page. The script was used
by the Cornerstone magazine to create an index for a book after
typesetting.
- Commify numbers (i)
- Formats numbers by placing commas before every 3 digits (eg: 1,200,573).
- Commify numbers (ii)
- A more compact script for versions of sed which recognise Extended RE's.
- Commify numbers (iii)
- Compare with (i). This script expects numeric input.
- Add decimals
- This impressive script adds a list of decimal numbers.
It pulls this off by transforming successive digits in each number
into an analogue format, where a=1, aa=2, aaa=3, etc, concatenating the
two analogue numbers, resolving carry, and transforming the numbers back
into decimal. See Greg Ubben's explanation in
Adding a list of decimal numbers on the
tutorials page.
- Split digest
- Recreates original email messages from a list digest.
The author says this should work `at least for digests generated by
Majordomo and #listserv, and FAQs using minimal digest format.'
- Sort/delimit/number a list
- A masterful script to sort, partition and number a list.
A thorough analysis of this script script given by the author in
A lookup-table counter
on the tutorials page.
- File polisher (troff)
- Very comprehensive suite of filters by Robert Marks
which perform a large number of beautifying operations on text files prior
to processing by troff. These scripts were used to produce camera-ready
output for the Australian School of Management between
1985 and 1995.
You can download a
gzipped tar archive
of the scripts, or individual scripts:
polish0.txt,
polish1.txt,
polish2.txt,
polish3.txt,
polish4.txt,
polish5.txt,
polish6.txt,
polish7.txt,
polish8.txt,
polish9.txt,
or visit
Robert's Web site.
- Convert DOS files for UNIX
- Changes DOS end-of-lines to UNIX end-of-lines.
- Convert UNIX files for DOS
- Changes UNIX end-of-lines to DOS end-of-lines.
- Text -> HTML
- Converts preformatted text to HTML ready for viewing.
- Intel assembler -> UNIX
assembler
- Converts Intel 386 assembly (MASM) code to Unix 386 assembly (gas) code.
- Strip C comments
- Strips comments from C source. Beware that code following a comment
is also removed. See next item...
- Strip C/C++ comments
- Strips comments from C/C++ source. Handles comments surrounded by code.
- Beautified directory tree
(UNIX)
- Indents the output of ls -lR according
to the depth of each directory. Makes output far easier to read.
-
Lowercase filenames (filter)
Uppercase filenames (filter)
-
Lowercase/uppercase list of filenames supplied from STDIN.
Example:
find /mnt/zeus/docs | tolower.sed | sh -x
-
Lowercase filenames (application)
Uppercase filenames (application)
- Lowercase/uppercase list of filenames supplied as command line arguments.
This version operates on files in current directory only.
Example:
down *.HTM *.INC *.TXT
- Capitalise words (i)
- Capitalises the first letter of each word.
- Capitalise words (ii)
- An interesting alternative approach.
- Capitalise words (iii)
- Another method. While simpler to follow, this one is CPU-intensive.
- Reverse text
- Reverses the order of characters on each line of input.
- Reverse text
- Longer but faster version.
- Reverse file
- Reverses the line order of a file, subject to the size of
the hold buffer.
- Join lines
- Joins all input on a single line.
- Un-double-space lines
- Change double-spaced lines to single-spaced.
- Centre lines
- Centres lines for an 80-column device. Easily adapted to different widths.
- Centre lines
- A slightly different approach.
- Number lines
- A short script to display output lines preceded by line numbers.
This is similar to the UNIX nl command, or cat -n.
- Number lines
- This version demonstrates a technique for manually calculating numbers.
- Number non-empty lines
- A short script to display output lines, preceding non-empty lines
with a line number. Empty lines do not affect the count.
This is not the same as cat -bn, which does count empty lines.
- Number non-empty lines
- This version demonstrates a technique for manually calculating numbers.
- Increment a number
- Interesting script to increment numbers.
- Squeeze blank lines
- Replace consecutive blank lines with one line, so that at most
one empty line separates two non-empty lines. Like cat -r.
- Find anagrams
- Seaarch for dictionary words in a string.
- Print basename of files
- Remove the directory prefix from a file path, and print remaining element.
Like UNIX basename.
Could easily be adapted for DOS conventions.
- Print path of files
- Remove the filename from a file path, and print remaining elements.
Like UNIX dirname.
Easily adapted to DOS conventions.
- Display beginning of file
- Display first 10 lines of a file. Like head.
- Show make targets
- Extracts targets for a file from a makefile.
Updated 15 Jun 1997