#!/bin/sh ######################################################################### # # FILE : tabulize # DATE : 26.01.2001 # AUTHOR : Patrick Meier / patrick.meier@gmx.net # DESCRIPTION : substitute whitspace with TABs or TABs with whitspace # # Copyrigth (C) 2001 by Patrick Meier, Switzerland # ######################################################################### PN=`basename "$0"` AWK="awk" ######################################################################### # Usage ######################################################################### Usage() { echo "$PN - substitute whitspace with TABs or TABs with whitspace (option -r)" echo "usage: $PN [-r] [-[number of spaces]] [file ...]" exit 1 } ######################################################################### # main ######################################################################### spaces=" " while [ $# -gt 0 ] do case "$1" in --help) Usage;; -h) Usage;; -r) converttabs="ok";; -*) numfiller="`echo $1 | sed 's/-//g'`";; *) break;; esac shift done if [ -n "$converttabs" ] then filler=" "; oldfiller=`getspaces $numfiller`; else filler=`getspaces $numfiller`; oldfiller=" "; fi TMPFILE="/tmp/$0$$" $AWK 'BEGIN {} { print $0 } END {}' "$@" >$TMPFILE cat $TMPFILE | sed " s/$filler/$oldfiller/g " rm $TMPFILE ######################################################################### # EOF #########################################################################