Unix scripts that you may find useful
Disclaimer and Terms: You may use these scripts for commercial or non-commercial use at your own risk, as long as you retain the copyright statements in the source code. These scripts are provided "AS IS" with no warranty whatsoever and are FREE for as long as you want to use them. You can edit and adapt them to your requirements without seeking permission from me. I only ask that you retain the credits where they are due.
- eXtract Source Code Comment (xscc.awk) is an awk script that extracts code or comments (or copyright statements) from a source file. It supports several programming languages, including Java/idl/C/C++/awk/Perl/bash/sh/ksh/html etc. Read more ...
- Source Lines of Code and Comment Count (slocc.sh) is a shell script that uses sh, sed and awk to produce lines of code and comment count for software source code. It supports various options including:
- walking entire directory tree and for each file in the directory tree (modifiable using find options) extract the raw code or comment or copyright statements in a parallel file hierarchy in a separate destination directory.
- supports flag to discard pretty formatting (such as an opening braces on a separate line, etc.) in the raw output as well as when counting lines. This can be useful to ensure that those who use K&R style braces are not at a disadvantage over those who use braces on separate lines.
- print count of lines of code, comment, copyright statements and comment/code ratio for each file in the tree.
- print directory level summary of lines of code, comment, copyright and comment/code ratio for each file.
- Unfold LDIF (LDAP Data Interchange Format) lines (unldif.sed) is a SED script that resulted from a need to process an ldif file via a shell script. Programs that output LDIF files fold a long field on multiple lines by inserting a line separator (either a linefeed or carriage return/linefeed pair) followed by a space. Processing such ldif files through another script becomes much easier if such lines were unfolded. That is exactly what this script does. It unfolds ldif entries that are folded (broken) across lines and writes them on a single line. Since most LDIF parsers accept unfolded lines, you do not have to fold it back. To fold them back (if you need to), see next item. Download ...
- Fold lines as per RFC2425 (fold.awk) is an AWK (use nawk on Solaris) script that implements line delimiting and folding as described in Section 5.8.1 "Line delimiting and folding" RFC2425. It can be used to fold MIME content at any given line width (defaults to 75 characters per line), and can be used to re-fold LDIF files after processing. Download ...
- text2html (text2html.awk) is an AWK script that converts a text file to html so that the text can be included in an html page. In particular, it converts special HTML characters so that they can be displayed verbatim. This script does not support syntax highlighting (unlike java2html or cpp2html programs), as it is intended for arbitrary text files, but it does support a few useful options as described in the usage of the program. Read more ...
This page has been visited