#!/bin/sh # # Change tabs to spaces in a text file # [ $# -ge 2 ] || { echo "usage: t2s tabsize file ..." >&2; exit 1; } case $1 in [0-9]*) ;; *) echo "t2s: Invalid tab size" >&2; exit 1;; esac tmpfile=$(mktemp ~/.t2s.XXXXXX) || exit 1 ts=$1 shift for f in "$@"; do expand -$ts "$f" >$tmpfile mv -f $tmpfile "$f" && chmod go+r "$f" done rm -f $tmpfile .